Allow resync on pvc when there is no error on the object

This commit is contained in:
Peter Schuurman
2022-03-02 11:26:16 -08:00
parent f320a800c2
commit edf2e03f35

View File

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