Skip to content

Commit 6c22859

Browse files
committed
Address race when adding finalizers
1 parent abf10b7 commit 6c22859

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

populator-machinery/controller.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,11 +722,15 @@ func (c *controller) ensureFinalizer(ctx context.Context, pvc *corev1.Persistent
722722

723723
if want {
724724
// Add the finalizer to the end of the list
725-
path := fmt.Sprintf("/metadata/finalizers/%d", len(finalizers))
726725
patch = []patchOp{
726+
{
727+
Op: "test",
728+
Path: "/metadata/finalizers",
729+
Value: finalizers,
730+
},
727731
{
728732
Op: "add",
729-
Path: path,
733+
Path: "/metadata/finalizers/-",
730734
Value: finalizer,
731735
},
732736
}

0 commit comments

Comments
 (0)