diff --git a/pkg/sidecar-controller/snapshot_controller_base.go b/pkg/sidecar-controller/snapshot_controller_base.go index ecb7ecd8..427d85de 100644 --- a/pkg/sidecar-controller/snapshot_controller_base.go +++ b/pkg/sidecar-controller/snapshot_controller_base.go @@ -41,7 +41,6 @@ import ( groupsnapshotlisters "github.com/kubernetes-csi/external-snapshotter/client/v6/listers/volumegroupsnapshot/v1alpha1" snapshotlisters "github.com/kubernetes-csi/external-snapshotter/client/v6/listers/volumesnapshot/v1" "github.com/kubernetes-csi/external-snapshotter/v6/pkg/snapshotter" - "github.com/kubernetes-csi/external-snapshotter/v6/pkg/utils" ) type csiSnapshotSideCarController struct { @@ -116,20 +115,12 @@ 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 (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. + // Considering the object is modified more than once during the workflow we are not relying on the + // "AnnVolumeSnapshotBeingCreated" annotation. Instead we will just check if newobj status has error + // and avoid the immediate re-queue. This allows the retry to happen with exponential backoff. newSnapContent := newObj.(*crdv1.VolumeSnapshotContent) if newSnapContent.Status != nil && newSnapContent.Status.Error != nil { - oldSnapContent := oldObj.(*crdv1.VolumeSnapshotContent) - _, newExists := newSnapContent.ObjectMeta.Annotations[utils.AnnVolumeSnapshotBeingCreated] - _, oldExists := oldSnapContent.ObjectMeta.Annotations[utils.AnnVolumeSnapshotBeingCreated] - if !newExists && oldExists { - return - } + return } ctrl.enqueueContentWork(newObj) },