diff --git a/pkg/sidecar-controller/snapshot_controller_base.go b/pkg/sidecar-controller/snapshot_controller_base.go index 2b2857c9..eb1984bc 100644 --- a/pkg/sidecar-controller/snapshot_controller_base.go +++ b/pkg/sidecar-controller/snapshot_controller_base.go @@ -97,17 +97,20 @@ func NewCSISnapshotSideCarController( cache.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { ctrl.enqueueContentWork(obj) }, UpdateFunc: func(oldObj, newObj interface{}) { - // If the CSI driver fails to create a snapshot and returns a failure, the CSI Snapshotter sidecar - // will remove the "AnnVolumeSnapshotBeingCreated" annotation from the VolumeSnapshotContent. + // If the CSI driver fails to create a snapshot and returns a failure (indicated by content.Status.Error), the + // CSI Snapshotter sidecar will remove the "AnnVolumeSnapshotBeingCreated" annotation from the + // VolumeSnapshotContent. // This will trigger a VolumeSnapshotContent update and it will cause the obj to be re-queued immediately // and CSI CreateSnapshot will be called again without exponential backoff. // So we are skipping the re-queue here to avoid CreateSnapshot being called without exponential backoff. newSnapContent := newObj.(*crdv1.VolumeSnapshotContent) - oldSnapContent := oldObj.(*crdv1.VolumeSnapshotContent) - _, newExists := newSnapContent.ObjectMeta.Annotations[utils.AnnVolumeSnapshotBeingCreated] - _, oldExists := oldSnapContent.ObjectMeta.Annotations[utils.AnnVolumeSnapshotBeingCreated] - if !newExists && oldExists { - return + if newSnapContent.Status.Error != nil { + oldSnapContent := oldObj.(*crdv1.VolumeSnapshotContent) + _, newExists := newSnapContent.ObjectMeta.Annotations[utils.AnnVolumeSnapshotBeingCreated] + _, oldExists := oldSnapContent.ObjectMeta.Annotations[utils.AnnVolumeSnapshotBeingCreated] + if !newExists && oldExists { + return + } } ctrl.enqueueContentWork(newObj) },