Skip to content

Commit

Permalink
Adjust the reconcile loop to use simpler logic from reconcile batch
Browse files Browse the repository at this point in the history
Change of the main reconcile loop to easy logic of the return
from the reconcile batch.

We only requeue when there is need, otherwise we do exit the reconcile
loop at the same place and individual reconcile functions control
if that should happen now or should be requeued.
  • Loading branch information
mpryc committed Apr 29, 2024
1 parent c91e31a commit 01cad5a
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions internal/controller/nonadminbackup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (r *NonAdminBackupReconciler) Reconcile(ctx context.Context, req ctrl.Reque
}

// Run Reconcile Batch as we have the NonAdminBackup object
reconcileExit, reconcileRequeue, reconcileErr := ReconcileBatch(
_, reconcileRequeue, reconcileErr := ReconcileBatch(
ReconcileFunc(func(...any) (bool, bool, error) {
return r.InitNonAdminBackup(ctx, rLog, &nab) // Phase: New
}),
Expand All @@ -95,17 +95,12 @@ func (r *NonAdminBackupReconciler) Reconcile(ctx context.Context, req ctrl.Reque
)

// Return vars from the ReconcileBatch
if reconcileExit {
return ctrl.Result{}, reconcileErr
} else if reconcileRequeue {
if reconcileRequeue {
return ctrl.Result{Requeue: true, RequeueAfter: requeueTimeSeconds * time.Second}, reconcileErr
} else if reconcileErr != nil {
return ctrl.Result{}, reconcileErr
} // No error and both reconcileExit and reconcileRequeue false, continue...
}

logger.V(1).Info(">>> Reconcile NonAdminBackup - loop end")

return ctrl.Result{}, nil
return ctrl.Result{}, reconcileErr
}

// SetupWithManager sets up the controller with the Manager.
Expand Down

0 comments on commit 01cad5a

Please sign in to comment.