Skip to content

Commit

Permalink
Use patch instead of update when adding finalizers
Browse files Browse the repository at this point in the history
Signed-off-by: Kingdon Barrett <kingdon@weave.works>
  • Loading branch information
Kingdon Barrett committed Jan 14, 2022
1 parent 8d61ff7 commit 441b48a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion controllers/kustomization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ func (r *KustomizationReconciler) Reconcile(ctx context.Context, req ctrl.Reques

// Add our finalizer if it does not exist
if !controllerutil.ContainsFinalizer(&kustomization, kustomizev1.KustomizationFinalizer) {
patch := client.MergeFrom(kustomization.DeepCopy())
controllerutil.AddFinalizer(&kustomization, kustomizev1.KustomizationFinalizer)
if err := r.Update(ctx, &kustomization); err != nil {
if err := r.Patch(ctx, &kustomization, patch); err != nil {
log.Error(err, "unable to register finalizer")
return ctrl.Result{}, err
}
Expand Down

0 comments on commit 441b48a

Please sign in to comment.