Skip to content

Commit fdd7b8a

Browse files
committed
[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 1ae5127 commit fdd7b8a

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

932932
// removePVCFinalizer removes a Finalizer for VolumeSnapshot Source PVC.
933933
func (ctrl *csiSnapshotCommonController) removePVCFinalizer(pvc *v1.PersistentVolumeClaim) error {
934-
return retry.RetryOnConflict(retry.DefaultRetry, func() error {
934+
err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
935935
// Get snapshot source which is a PVC
936936
newPvc, err := ctrl.client.CoreV1().PersistentVolumeClaims(pvc.Namespace).Get(context.TODO(), pvc.Name, metav1.GetOptions{})
937937
if err != nil {
@@ -941,12 +941,16 @@ func (ctrl *csiSnapshotCommonController) removePVCFinalizer(pvc *v1.PersistentVo
941941
newPvc.ObjectMeta.Finalizers = utils.RemoveString(newPvc.ObjectMeta.Finalizers, utils.PVCFinalizer)
942942
_, err = ctrl.client.CoreV1().PersistentVolumeClaims(newPvc.Namespace).Update(context.TODO(), newPvc, metav1.UpdateOptions{})
943943
if err != nil {
944-
return newControllerUpdateError(newPvc.Name, err.Error())
944+
return err
945945
}
946946

947947
klog.V(5).Infof("Removed protection finalizer from persistent volume claim %s", pvc.Name)
948948
return nil
949949
})
950+
if err != nil {
951+
return newControllerUpdateError(pvc.Name, err.Error())
952+
}
953+
return nil
950954
}
951955

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

0 commit comments

Comments
 (0)