Skip to content

Commit d3243e0

Browse files
authored
Merge pull request #121 from zhucan/status-52
add status subresources for volumeSnapshot
2 parents 567d14c + a23be2d commit d3243e0

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

cmd/csi-snapshotter/create_crd.go

+7
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ func CreateCRD(clientset apiextensionsclient.Interface) error {
3838
Plural: crdv1.VolumeSnapshotClassResourcePlural,
3939
Kind: reflect.TypeOf(crdv1.VolumeSnapshotClass{}).Name(),
4040
},
41+
Subresources: &apiextensionsv1beta1.CustomResourceSubresources{
42+
Status: &apiextensionsv1beta1.CustomResourceSubresourceStatus{},
43+
},
4144
},
4245
}
46+
4347
res, err := clientset.ApiextensionsV1beta1().CustomResourceDefinitions().Create(crd)
4448

4549
if err != nil && !apierrors.IsAlreadyExists(err) {
@@ -80,6 +84,9 @@ func CreateCRD(clientset apiextensionsclient.Interface) error {
8084
Plural: crdv1.VolumeSnapshotResourcePlural,
8185
Kind: reflect.TypeOf(crdv1.VolumeSnapshot{}).Name(),
8286
},
87+
Subresources: &apiextensionsv1beta1.CustomResourceSubresources{
88+
Status: &apiextensionsv1beta1.CustomResourceSubresourceStatus{},
89+
},
8390
},
8491
}
8592
res, err = clientset.ApiextensionsV1beta1().CustomResourceDefinitions().Create(crd)

deploy/kubernetes/rbac.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ rules:
4444
- apiGroups: ["snapshot.storage.k8s.io"]
4545
resources: ["volumesnapshots"]
4646
verbs: ["get", "list", "watch", "update"]
47+
- apiGroups: ["snapshot.storage.k8s.io"]
48+
resources: ["volumesnapshots/status"]
49+
verbs: ["update"]
4750
- apiGroups: ["apiextensions.k8s.io"]
4851
resources: ["customresourcedefinitions"]
49-
verbs: ["create", "list", "watch", "delete"]
52+
verbs: ["create", "list", "watch", "delete", "get", "update"]
5053

5154
---
5255
kind: ClusterRoleBinding

pkg/controller/snapshot_controller.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,9 @@ func (ctrl *csiSnapshotController) updateSnapshotErrorStatusWithEvent(snapshot *
422422
Message: message,
423423
}
424424
snapshotClone.Status.Error = statusError
425-
426425
snapshotClone.Status.ReadyToUse = false
427-
newSnapshot, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshotClone.Namespace).Update(snapshotClone)
426+
newSnapshot, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshotClone.Namespace).UpdateStatus(snapshotClone)
427+
428428
if err != nil {
429429
klog.V(4).Infof("updating VolumeSnapshot[%s] error status failed %v", snapshotKey(snapshot), err)
430430
return err
@@ -848,7 +848,7 @@ func (ctrl *csiSnapshotController) updateSnapshotStatus(snapshot *crdv1.VolumeSn
848848
status.RestoreSize = resource.NewQuantity(size, resource.BinarySI)
849849
}
850850
snapshotClone.Status = status
851-
newSnapshotObj, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshotClone.Namespace).Update(snapshotClone)
851+
newSnapshotObj, err := ctrl.clientset.SnapshotV1alpha1().VolumeSnapshots(snapshotClone.Namespace).UpdateStatus(snapshotClone)
852852
if err != nil {
853853
return nil, newControllerUpdateError(snapshotKey(snapshot), err.Error())
854854
}

0 commit comments

Comments
 (0)