From d99dcd59efdcbeb042a4c4a3b62fd45639a09fc2 Mon Sep 17 00:00:00 2001 From: Mike Wilson Date: Tue, 23 Jan 2024 13:04:24 -0500 Subject: [PATCH] Reduce spammy reconciler messages. The reconciler will now log the "already registered" messages at the trace level instead of at debug, which should reduce how spammy this log entry is. --- lib/services/reconciler.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/services/reconciler.go b/lib/services/reconciler.go index f92e869695bff..fc0d6678efe76 100644 --- a/lib/services/reconciler.go +++ b/lib/services/reconciler.go @@ -84,7 +84,12 @@ func NewReconciler[T Reconciled](cfg ReconcilerConfig[T]) (*Reconciler[T], error } return &Reconciler[T]{ cfg: cfg, - log: cfg.Log, + // We do a WithFields here to force this into a *logrus.Entry, which has the ability to + // log at the Trace level. If we were to change this in ReconcilerConfig, we'd have to + // refactor existing code to use *logrus.Entry instead of logrus.FieldLogger, and with + // the eventual change to slog, it seems easier to do this for now until this can be + // changed to slog. + log: cfg.Log.WithFields(nil), }, nil } @@ -95,7 +100,7 @@ func NewReconciler[T Reconciled](cfg ReconcilerConfig[T]) (*Reconciler[T], error // to enable dynamically registered resources. type Reconciler[T Reconciled] struct { cfg ReconcilerConfig[T] - log logrus.FieldLogger + log *logrus.Entry } // Reconcile reconciles currently registered resources with new resources and @@ -190,6 +195,6 @@ func (r *Reconciler[T]) processNewResource(ctx context.Context, currentResources return nil } - r.log.Debugf("%v %v is already registered.", kind, name) + r.log.Tracef("%v %v is already registered.", kind, name) return nil }