From 3c94365267a20edcf59302133212018e10a5a0f7 Mon Sep 17 00:00:00 2001 From: razo7 Date: Wed, 5 Jul 2023 17:12:51 +0300 Subject: [PATCH] End reconcile after finalizer addition The reconcile should end when a finalizer has been added. Without ending the reconcile a new reconcile will allways be triggered and will result in a duplicate reboot to the node (until FAR would have a status to the CR) --- controllers/fenceagentsremediation_controller.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/controllers/fenceagentsremediation_controller.go b/controllers/fenceagentsremediation_controller.go index 61b288a3..a021b7ad 100644 --- a/controllers/fenceagentsremediation_controller.go +++ b/controllers/fenceagentsremediation_controller.go @@ -106,6 +106,10 @@ func (r *FenceAgentsRemediationReconciler) Reconcile(ctx context.Context, req ct if err := r.Client.Update(context.Background(), far); err != nil { return emptyResult, fmt.Errorf("failed to add finalizer to the CR - %w", err) } + r.Log.Info("Finalizer was added", "CR Name", req.Name) + return emptyResult, nil + // TODO: should return Requeue: true when the CR has a status and not end reconcile with empty result when a finalizer has been added + //return ctrl.Result{Requeue: true}, nil } else if controllerutil.ContainsFinalizer(far, v1alpha1.FARFinalizer) && !far.ObjectMeta.DeletionTimestamp.IsZero() { // Delete CR only when a finalizer and DeletionTimestamp are set r.Log.Info("CR's deletion timestamp is not zero, and FAR finalizer exists", "CR Name", req.Name)