Skip to content

Commit 5d5431f

Browse files
authored
Merge pull request kubernetes-csi#871 from sameshai/bugfix-778
external-snapshotter constantly retrying CreateSnapshot calls on error w/o backoff
2 parents dd523a0 + 7fac9cd commit 5d5431f

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

pkg/sidecar-controller/snapshot_controller_base.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import (
4141
groupsnapshotlisters "github.com/kubernetes-csi/external-snapshotter/client/v6/listers/volumegroupsnapshot/v1alpha1"
4242
snapshotlisters "github.com/kubernetes-csi/external-snapshotter/client/v6/listers/volumesnapshot/v1"
4343
"github.com/kubernetes-csi/external-snapshotter/v6/pkg/snapshotter"
44-
"github.com/kubernetes-csi/external-snapshotter/v6/pkg/utils"
4544
)
4645

4746
type csiSnapshotSideCarController struct {
@@ -116,20 +115,12 @@ func NewCSISnapshotSideCarController(
116115
cache.ResourceEventHandlerFuncs{
117116
AddFunc: func(obj interface{}) { ctrl.enqueueContentWork(obj) },
118117
UpdateFunc: func(oldObj, newObj interface{}) {
119-
// If the CSI driver fails to create a snapshot and returns a failure (indicated by content.Status.Error), the
120-
// CSI Snapshotter sidecar will remove the "AnnVolumeSnapshotBeingCreated" annotation from the
121-
// VolumeSnapshotContent.
122-
// This will trigger a VolumeSnapshotContent update and it will cause the obj to be re-queued immediately
123-
// and CSI CreateSnapshot will be called again without exponential backoff.
124-
// So we are skipping the re-queue here to avoid CreateSnapshot being called without exponential backoff.
118+
// Considering the object is modified more than once during the workflow we are not relying on the
119+
// "AnnVolumeSnapshotBeingCreated" annotation. Instead we will just check if newobj status has error
120+
// and avoid the immediate re-queue. This allows the retry to happen with exponential backoff.
125121
newSnapContent := newObj.(*crdv1.VolumeSnapshotContent)
126122
if newSnapContent.Status != nil && newSnapContent.Status.Error != nil {
127-
oldSnapContent := oldObj.(*crdv1.VolumeSnapshotContent)
128-
_, newExists := newSnapContent.ObjectMeta.Annotations[utils.AnnVolumeSnapshotBeingCreated]
129-
_, oldExists := oldSnapContent.ObjectMeta.Annotations[utils.AnnVolumeSnapshotBeingCreated]
130-
if !newExists && oldExists {
131-
return
132-
}
123+
return
133124
}
134125
ctrl.enqueueContentWork(newObj)
135126
},

0 commit comments

Comments
 (0)