Skip to content

Commit 1ef66de

Browse files
Fricounetdatadog-compute-robot
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 37da604 commit 1ef66de

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
@@ -1009,7 +1009,7 @@ func (ctrl *csiSnapshotCommonController) ensurePVCFinalizer(snapshot *crdv1.Volu
10091009

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

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

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

0 commit comments

Comments
 (0)