Allow resync on pvc when there is no error on the object
This commit is contained in:
@@ -97,17 +97,20 @@ func NewCSISnapshotSideCarController(
|
|||||||
cache.ResourceEventHandlerFuncs{
|
cache.ResourceEventHandlerFuncs{
|
||||||
AddFunc: func(obj interface{}) { ctrl.enqueueContentWork(obj) },
|
AddFunc: func(obj interface{}) { ctrl.enqueueContentWork(obj) },
|
||||||
UpdateFunc: func(oldObj, newObj interface{}) {
|
UpdateFunc: func(oldObj, newObj interface{}) {
|
||||||
// If the CSI driver fails to create a snapshot and returns a failure, the CSI Snapshotter sidecar
|
// If the CSI driver fails to create a snapshot and returns a failure (indicated by content.Status.Error), the
|
||||||
// will remove the "AnnVolumeSnapshotBeingCreated" annotation from the VolumeSnapshotContent.
|
// 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
|
// 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.
|
// 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.
|
// So we are skipping the re-queue here to avoid CreateSnapshot being called without exponential backoff.
|
||||||
newSnapContent := newObj.(*crdv1.VolumeSnapshotContent)
|
newSnapContent := newObj.(*crdv1.VolumeSnapshotContent)
|
||||||
oldSnapContent := oldObj.(*crdv1.VolumeSnapshotContent)
|
if newSnapContent.Status.Error != nil {
|
||||||
_, newExists := newSnapContent.ObjectMeta.Annotations[utils.AnnVolumeSnapshotBeingCreated]
|
oldSnapContent := oldObj.(*crdv1.VolumeSnapshotContent)
|
||||||
_, oldExists := oldSnapContent.ObjectMeta.Annotations[utils.AnnVolumeSnapshotBeingCreated]
|
_, newExists := newSnapContent.ObjectMeta.Annotations[utils.AnnVolumeSnapshotBeingCreated]
|
||||||
if !newExists && oldExists {
|
_, oldExists := oldSnapContent.ObjectMeta.Annotations[utils.AnnVolumeSnapshotBeingCreated]
|
||||||
return
|
if !newExists && oldExists {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ctrl.enqueueContentWork(newObj)
|
ctrl.enqueueContentWork(newObj)
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user