Skip to content

Commit 2418fb3

Browse files
Fricounetantoine-gaillard
authored andcommitted
[snapshot-controller] Do not modify error when retrying PVC finalizer removal
The `RetryOnConflict` function only retries the update of an object if the retured error is an unmodified 429 error. This commit fixes the retry to modify the error into a `controllerUpdateError` only after the `RetryOnConflict` function finishes.
1 parent 4b526f2 commit 2418fb3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pkg/common-controller/snapshot_controller.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ func (ctrl *csiSnapshotCommonController) ensurePVCFinalizer(snapshot *crdv1.Volu
10101010

10111011
// removePVCFinalizer removes a Finalizer for VolumeSnapshot Source PVC.
10121012
func (ctrl *csiSnapshotCommonController) removePVCFinalizer(pvc *v1.PersistentVolumeClaim) error {
1013-
return retry.RetryOnConflict(retry.DefaultRetry, func() error {
1013+
err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
10141014
// Get snapshot source which is a PVC
10151015
newPvc, err := ctrl.client.CoreV1().PersistentVolumeClaims(pvc.Namespace).Get(context.TODO(), pvc.Name, metav1.GetOptions{})
10161016
if err != nil {
@@ -1020,12 +1020,16 @@ func (ctrl *csiSnapshotCommonController) removePVCFinalizer(pvc *v1.PersistentVo
10201020
newPvc.ObjectMeta.Finalizers = utils.RemoveString(newPvc.ObjectMeta.Finalizers, utils.PVCFinalizer)
10211021
_, err = ctrl.client.CoreV1().PersistentVolumeClaims(newPvc.Namespace).Update(context.TODO(), newPvc, metav1.UpdateOptions{})
10221022
if err != nil {
1023-
return newControllerUpdateError(newPvc.Name, err.Error())
1023+
return err
10241024
}
10251025

10261026
klog.V(5).Infof("Removed protection finalizer from persistent volume claim %s", pvc.Name)
10271027
return nil
10281028
})
1029+
if err != nil {
1030+
return newControllerUpdateError(pvc.Name, err.Error())
1031+
}
1032+
return nil
10291033
}
10301034

10311035
// isPVCBeingUsed checks if a PVC is being used as a source to create a snapshot.

0 commit comments

Comments
 (0)