Emit event even if status update fails so user can see it

This commit is contained in:
xing-yang
2020-08-09 04:16:16 +00:00
parent 39fb3e4666
commit 2a990923fd
2 changed files with 6 additions and 6 deletions

View File

@@ -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)