From dd138bd6ce2328021e48cf79981b86d9b52e7934 Mon Sep 17 00:00:00 2001 From: Hans Rakers Date: Wed, 14 Aug 2024 10:23:39 +0200 Subject: [PATCH] feat: Log start/end of reconciliation --- controllers/utils/base_reconciler.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/controllers/utils/base_reconciler.go b/controllers/utils/base_reconciler.go index 082d3dd0..26594e9f 100644 --- a/controllers/utils/base_reconciler.go +++ b/controllers/utils/base_reconciler.go @@ -361,6 +361,8 @@ 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 @@ -368,12 +370,18 @@ func (r *ReconciliationRunner) RunReconciliationStages(fns ...CloudStackReconcil 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 {