Skip to content

Commit

Permalink
feat: Log start/end of reconciliation
Browse files Browse the repository at this point in the history
  • Loading branch information
hrak committed Aug 14, 2024
1 parent bc2002e commit dd138bd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions controllers/utils/base_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,19 +361,27 @@ func (r *ReconciliationRunner) ShouldReturn(rslt ctrl.Result, err error) bool {
// RunReconciliationStages runs CloudStackReconcilerMethods in order and exits if an error or requeue condition is set.
// On exit patches changes back to API.
func (r *ReconciliationRunner) RunReconciliationStages(fns ...CloudStackReconcilerMethod) (ctrl.Result, error) {
r.Log.Info("Starting reconciliation")

for _, fn := range fns {
if rslt, err := fn(); err != nil {
return rslt, err
} else if rslt.Requeue || rslt.RequeueAfter != time.Duration(0) || r.returnEarly {
return rslt, nil
}
}

r.Log.Info("Finished reconciliation",
"kind", r.ReconciliationSubject.GetObjectKind().GroupVersionKind().Kind,
"name", r.ReconciliationSubject.GetName())

return ctrl.Result{}, nil
}

// RunBaseReconciliationStages runs the base reconciliation stages which are to setup the logger, get the reconciliation
// subject, get CAPI and CloudStackClusters, and call either r.Reconcile or r.ReconcileDelete.
func (r *ReconciliationRunner) RunBaseReconciliationStages() (res ctrl.Result, retErr error) {

defer func() {
if r.Patcher != nil {
if err := r.Patcher.Patch(r.RequestCtx, r.ReconciliationSubject); err != nil {
Expand Down

0 comments on commit dd138bd

Please sign in to comment.