Skip to content

Commit 8e5ae41

Browse files
authored
Merge pull request #666 from pwschuurman/bugfix-533-resync-on-no-error
Allow resync on VolumeSnapshotContent when there is no error from CreateSnapshot
2 parents f320a80 + edf2e03 commit 8e5ae41

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

pkg/sidecar-controller/snapshot_controller_base.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,20 @@ func NewCSISnapshotSideCarController(
9797
cache.ResourceEventHandlerFuncs{
9898
AddFunc: func(obj interface{}) { ctrl.enqueueContentWork(obj) },
9999
UpdateFunc: func(oldObj, newObj interface{}) {
100-
// If the CSI driver fails to create a snapshot and returns a failure, the CSI Snapshotter sidecar
101-
// will remove the "AnnVolumeSnapshotBeingCreated" annotation from the VolumeSnapshotContent.
100+
// If the CSI driver fails to create a snapshot and returns a failure (indicated by content.Status.Error), the
101+
// CSI Snapshotter sidecar will remove the "AnnVolumeSnapshotBeingCreated" annotation from the
102+
// VolumeSnapshotContent.
102103
// This will trigger a VolumeSnapshotContent update and it will cause the obj to be re-queued immediately
103104
// and CSI CreateSnapshot will be called again without exponential backoff.
104105
// So we are skipping the re-queue here to avoid CreateSnapshot being called without exponential backoff.
105106
newSnapContent := newObj.(*crdv1.VolumeSnapshotContent)
106-
oldSnapContent := oldObj.(*crdv1.VolumeSnapshotContent)
107-
_, newExists := newSnapContent.ObjectMeta.Annotations[utils.AnnVolumeSnapshotBeingCreated]
108-
_, oldExists := oldSnapContent.ObjectMeta.Annotations[utils.AnnVolumeSnapshotBeingCreated]
109-
if !newExists && oldExists {
110-
return
107+
if newSnapContent.Status.Error != nil {
108+
oldSnapContent := oldObj.(*crdv1.VolumeSnapshotContent)
109+
_, newExists := newSnapContent.ObjectMeta.Annotations[utils.AnnVolumeSnapshotBeingCreated]
110+
_, oldExists := oldSnapContent.ObjectMeta.Annotations[utils.AnnVolumeSnapshotBeingCreated]
111+
if !newExists && oldExists {
112+
return
113+
}
111114
}
112115
ctrl.enqueueContentWork(newObj)
113116
},

0 commit comments

Comments
 (0)