Skip to content

Commit 2a99092

Browse files
committed
Emit event even if status update fails so user can see it
1 parent 39fb3e4 commit 2a99092

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

pkg/common-controller/snapshot_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -741,14 +741,14 @@ func (ctrl *csiSnapshotCommonController) updateSnapshotErrorStatusWithEvent(snap
741741
snapshotClone.Status.ReadyToUse = &ready
742742
newSnapshot, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshots(snapshotClone.Namespace).UpdateStatus(context.TODO(), snapshotClone, metav1.UpdateOptions{})
743743

744+
// Emit the event even if the status update fails so that user can see the error
745+
ctrl.eventRecorder.Event(newSnapshot, eventtype, reason, message)
746+
744747
if err != nil {
745748
klog.V(4).Infof("updating VolumeSnapshot[%s] error status failed %v", utils.SnapshotKey(snapshot), err)
746749
return err
747750
}
748751

749-
// Emit the event only when the status change happens
750-
ctrl.eventRecorder.Event(newSnapshot, eventtype, reason, message)
751-
752752
_, err = ctrl.storeSnapshotUpdate(newSnapshot)
753753
if err != nil {
754754
klog.V(4).Infof("updating VolumeSnapshot[%s] error status: cannot update internal cache %v", utils.SnapshotKey(snapshot), err)

pkg/sidecar-controller/snapshot_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,14 @@ func (ctrl *csiSnapshotSideCarController) updateContentErrorStatusWithEvent(cont
159159
contentClone.Status.ReadyToUse = &ready
160160
newContent, err := ctrl.clientset.SnapshotV1beta1().VolumeSnapshotContents().UpdateStatus(context.TODO(), contentClone, metav1.UpdateOptions{})
161161

162+
// Emit the event even if the status update fails so that user can see the error
163+
ctrl.eventRecorder.Event(newContent, eventtype, reason, message)
164+
162165
if err != nil {
163166
klog.V(4).Infof("updating VolumeSnapshotContent[%s] error status failed %v", content.Name, err)
164167
return err
165168
}
166169

167-
// Emit the event only when the status change happens
168-
ctrl.eventRecorder.Event(newContent, eventtype, reason, message)
169-
170170
_, err = ctrl.storeContentUpdate(newContent)
171171
if err != nil {
172172
klog.V(4).Infof("updating VolumeSnapshotContent[%s] error status: cannot update internal cache %v", content.Name, err)

0 commit comments

Comments
 (0)