Skip to content

Commit

Permalink
Merge pull request #535 from kingdonb/patch-finalizers
Browse files Browse the repository at this point in the history
Use patch instead of update when adding finalizers
  • Loading branch information
stefanprodan authored Jan 14, 2022
2 parents 4e8fd15 + 441b48a commit b18584a
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 @@ -152,8 +152,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 b18584a

Please sign in to comment.