Skip to content

Commit

Permalink
fix(controllers): return early when adding finalizer
Browse files Browse the repository at this point in the history
  • Loading branch information
tronghn committed Dec 20, 2024
1 parent d558418 commit 0fc003f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions controllers/jwker_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,13 @@ func (r *JwkerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
}

if !controllerutil.ContainsFinalizer(&jwker, finalizer) {
controllerutil.AddFinalizer(&jwker, finalizer)
if err := r.Client.Update(ctx, &jwker); err != nil {
if err := r.updateJwker(ctx, jwker, func(existing *jwkerv1.Jwker) error {
controllerutil.AddFinalizer(existing, finalizer)
return r.Update(ctx, existing)
}); err != nil {
return ctrl.Result{}, fmt.Errorf("registering finalizer: %w", err)
}
return ctrl.Result{}, nil
}

hash, err = jwker.Spec.Hash()
Expand Down

0 comments on commit 0fc003f

Please sign in to comment.