Skip to content

Commit

Permalink
fix: Use Patch instead of Update to remove finalizers
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Jul 13, 2024
1 parent c79ac0c commit d9e3ee5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion controllers/objecttemplate_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,9 @@ func (r *ObjectTemplateReconciler) finalize(ctx context.Context, obj *templatesv
r.doFinalize(ctx, obj)

// Remove our finalizer from the list and update it
patch := client.MergeFrom(obj.DeepCopy())
controllerutil.RemoveFinalizer(obj, templatesv1alpha1.ObjectTemplateFinalizer)
if err := r.Update(ctx, obj, client.FieldOwner(r.FieldManager)); err != nil {
if err := r.Patch(ctx, obj, patch, client.FieldOwner(r.FieldManager)); err != nil {
return ctrl.Result{}, err
}

Expand Down
3 changes: 2 additions & 1 deletion controllers/texttemplate_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,9 @@ func (r *TextTemplateReconciler) finalize(ctx context.Context, obj *templatesv1a
r.watchesUtil.removeWatchesForTemplate(client.ObjectKeyFromObject(obj))

// Remove our finalizer from the list and update it
patch := client.MergeFrom(obj.DeepCopy())
controllerutil.RemoveFinalizer(obj, templatesv1alpha1.TextTemplateFinalizer)
if err := r.Update(ctx, obj, client.FieldOwner(r.FieldManager)); err != nil {
if err := r.Patch(ctx, obj, patch, client.FieldOwner(r.FieldManager)); err != nil {
return ctrl.Result{}, err
}

Expand Down

0 comments on commit d9e3ee5

Please sign in to comment.