Skip to content

Commit

Permalink
Merge pull request #121 from zhucan/status-52
Browse files Browse the repository at this point in the history
add status subresources for volumeSnapshot
  • Loading branch information
k8s-ci-robot authored Jun 12, 2019
2 parents 567d14c + a23be2d commit d3243e0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
7 changes: 7 additions & 0 deletions cmd/csi-snapshotter/create_crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ func CreateCRD(clientset apiextensionsclient.Interface) error {
Plural: crdv1.VolumeSnapshotClassResourcePlural,
Kind: reflect.TypeOf(crdv1.VolumeSnapshotClass{}).Name(),
},
Subresources: &apiextensionsv1beta1.CustomResourceSubresources{
Status: &apiextensionsv1beta1.CustomResourceSubresourceStatus{},
},
},
}

res, err := clientset.ApiextensionsV1beta1().CustomResourceDefinitions().Create(crd)

if err != nil && !apierrors.IsAlreadyExists(err) {
Expand Down Expand Up @@ -80,6 +84,9 @@ func CreateCRD(clientset apiextensionsclient.Interface) error {
Plural: crdv1.VolumeSnapshotResourcePlural,
Kind: reflect.TypeOf(crdv1.VolumeSnapshot{}).Name(),
},
Subresources: &apiextensionsv1beta1.CustomResourceSubresources{
Status: &apiextensionsv1beta1.CustomResourceSubresourceStatus{},
},
},
}
res, err = clientset.ApiextensionsV1beta1().CustomResourceDefinitions().Create(crd)
Expand Down
5 changes: 4 additions & 1 deletion deploy/kubernetes/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ rules:
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshots"]
verbs: ["get", "list", "watch", "update"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshots/status"]
verbs: ["update"]
- apiGroups: ["apiextensions.k8s.io"]
resources: ["customresourcedefinitions"]
verbs: ["create", "list", "watch", "delete"]
verbs: ["create", "list", "watch", "delete", "get", "update"]

---
kind: ClusterRoleBinding
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/snapshot_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,9 @@ func (ctrl *csiSnapshotController) updateSnapshotErrorStatusWithEvent(snapshot *
Message: message,
}
snapshotClone.Status.Error = statusError

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 {
klog.V(4).Infof("updating VolumeSnapshot[%s] error status failed %v", snapshotKey(snapshot), err)
return err
Expand Down Expand Up @@ -848,7 +848,7 @@ func (ctrl *csiSnapshotController) updateSnapshotStatus(snapshot *crdv1.VolumeSn
status.RestoreSize = resource.NewQuantity(size, resource.BinarySI)
}
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 {
return nil, newControllerUpdateError(snapshotKey(snapshot), err.Error())
}
Expand Down

0 comments on commit d3243e0

Please sign in to comment.