Merge pull request #121 from zhucan/status-52
add status subresources for volumeSnapshot
This commit is contained in:
@@ -38,8 +38,12 @@ func CreateCRD(clientset apiextensionsclient.Interface) error {
|
|||||||
Plural: crdv1.VolumeSnapshotClassResourcePlural,
|
Plural: crdv1.VolumeSnapshotClassResourcePlural,
|
||||||
Kind: reflect.TypeOf(crdv1.VolumeSnapshotClass{}).Name(),
|
Kind: reflect.TypeOf(crdv1.VolumeSnapshotClass{}).Name(),
|
||||||
},
|
},
|
||||||
|
Subresources: &apiextensionsv1beta1.CustomResourceSubresources{
|
||||||
|
Status: &apiextensionsv1beta1.CustomResourceSubresourceStatus{},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := clientset.ApiextensionsV1beta1().CustomResourceDefinitions().Create(crd)
|
res, err := clientset.ApiextensionsV1beta1().CustomResourceDefinitions().Create(crd)
|
||||||
|
|
||||||
if err != nil && !apierrors.IsAlreadyExists(err) {
|
if err != nil && !apierrors.IsAlreadyExists(err) {
|
||||||
@@ -80,6 +84,9 @@ func CreateCRD(clientset apiextensionsclient.Interface) error {
|
|||||||
Plural: crdv1.VolumeSnapshotResourcePlural,
|
Plural: crdv1.VolumeSnapshotResourcePlural,
|
||||||
Kind: reflect.TypeOf(crdv1.VolumeSnapshot{}).Name(),
|
Kind: reflect.TypeOf(crdv1.VolumeSnapshot{}).Name(),
|
||||||
},
|
},
|
||||||
|
Subresources: &apiextensionsv1beta1.CustomResourceSubresources{
|
||||||
|
Status: &apiextensionsv1beta1.CustomResourceSubresourceStatus{},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
res, err = clientset.ApiextensionsV1beta1().CustomResourceDefinitions().Create(crd)
|
res, err = clientset.ApiextensionsV1beta1().CustomResourceDefinitions().Create(crd)
|
||||||
|
@@ -44,9 +44,12 @@ rules:
|
|||||||
- apiGroups: ["snapshot.storage.k8s.io"]
|
- apiGroups: ["snapshot.storage.k8s.io"]
|
||||||
resources: ["volumesnapshots"]
|
resources: ["volumesnapshots"]
|
||||||
verbs: ["get", "list", "watch", "update"]
|
verbs: ["get", "list", "watch", "update"]
|
||||||
|
- apiGroups: ["snapshot.storage.k8s.io"]
|
||||||
|
resources: ["volumesnapshots/status"]
|
||||||
|
verbs: ["update"]
|
||||||
- apiGroups: ["apiextensions.k8s.io"]
|
- apiGroups: ["apiextensions.k8s.io"]
|
||||||
resources: ["customresourcedefinitions"]
|
resources: ["customresourcedefinitions"]
|
||||||
verbs: ["create", "list", "watch", "delete"]
|
verbs: ["create", "list", "watch", "delete", "get", "update"]
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: ClusterRoleBinding
|
kind: ClusterRoleBinding
|
||||||
|
@@ -422,9 +422,9 @@ func (ctrl *csiSnapshotController) updateSnapshotErrorStatusWithEvent(snapshot *
|
|||||||
Message: message,
|
Message: message,
|
||||||
}
|
}
|
||||||
snapshotClone.Status.Error = statusError
|
snapshotClone.Status.Error = statusError
|
||||||
|
|
||||||
snapshotClone.Status.ReadyToUse = false
|
snapshotClone.Status.ReadyToUse = false
|
||||||
newSnapshot, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshotClone.Namespace).Update(snapshotClone)
|
newSnapshot, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshotClone.Namespace).UpdateStatus(snapshotClone)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.V(4).Infof("updating VolumeSnapshot[%s] error status failed %v", snapshotKey(snapshot), err)
|
klog.V(4).Infof("updating VolumeSnapshot[%s] error status failed %v", snapshotKey(snapshot), err)
|
||||||
return err
|
return err
|
||||||
@@ -848,7 +848,7 @@ func (ctrl *csiSnapshotController) updateSnapshotStatus(snapshot *crdv1.VolumeSn
|
|||||||
status.RestoreSize = resource.NewQuantity(size, resource.BinarySI)
|
status.RestoreSize = resource.NewQuantity(size, resource.BinarySI)
|
||||||
}
|
}
|
||||||
snapshotClone.Status = status
|
snapshotClone.Status = status
|
||||||
newSnapshotObj, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshotClone.Namespace).Update(snapshotClone)
|
newSnapshotObj, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshotClone.Namespace).UpdateStatus(snapshotClone)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newControllerUpdateError(snapshotKey(snapshot), err.Error())
|
return nil, newControllerUpdateError(snapshotKey(snapshot), err.Error())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user