diff --git a/pkg/common-controller/snapshot_controller.go b/pkg/common-controller/snapshot_controller.go index d4acf431..15a5131e 100644 --- a/pkg/common-controller/snapshot_controller.go +++ b/pkg/common-controller/snapshot_controller.go @@ -741,14 +741,14 @@ func (ctrl *csiSnapshotCommonController) updateSnapshotErrorStatusWithEvent(snap snapshotClone.Status.ReadyToUse = &ready newSnapshot, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(snapshotClone.Namespace).UpdateStatus(context.TODO(), snapshotClone, metav1.UpdateOptions{}) + // Emit the event even if the status update fails so that user can see the error + ctrl.eventRecorder.Event(newSnapshot, eventtype, reason, message) + if err != nil { klog.V(4).Infof("updating VolumeSnapshot[%s] error status failed %v", utils.SnapshotKey(snapshot), err) return err } - // Emit the event only when the status change happens - ctrl.eventRecorder.Event(newSnapshot, eventtype, reason, message) - _, err = ctrl.storeSnapshotUpdate(newSnapshot) if err != nil { klog.V(4).Infof("updating VolumeSnapshot[%s] error status: cannot update internal cache %v", utils.SnapshotKey(snapshot), err) diff --git a/pkg/sidecar-controller/snapshot_controller.go b/pkg/sidecar-controller/snapshot_controller.go index ff1abf11..7109660e 100644 --- a/pkg/sidecar-controller/snapshot_controller.go +++ b/pkg/sidecar-controller/snapshot_controller.go @@ -159,14 +159,14 @@ func (ctrl *csiSnapshotSideCarController) updateContentErrorStatusWithEvent(cont contentClone.Status.ReadyToUse = &ready newContent, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshotContents().UpdateStatus(context.TODO(), contentClone, metav1.UpdateOptions{}) + // Emit the event even if the status update fails so that user can see the error + ctrl.eventRecorder.Event(newContent, eventtype, reason, message) + if err != nil { klog.V(4).Infof("updating VolumeSnapshotContent[%s] error status failed %v", content.Name, err) return err } - // Emit the event only when the status change happens - ctrl.eventRecorder.Event(newContent, eventtype, reason, message) - _, err = ctrl.storeContentUpdate(newContent) if err != nil { klog.V(4).Infof("updating VolumeSnapshotContent[%s] error status: cannot update internal cache %v", content.Name, err)