From 58dcbb2613fe35e1149c2c8aebff330e18afcf1f Mon Sep 17 00:00:00 2001 From: Guilherme Cassolato Date: Fri, 25 Oct 2024 10:19:27 +0200 Subject: [PATCH] controller: debug logging Signed-off-by: Guilherme Cassolato --- controller/controller.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/controller/controller.go b/controller/controller.go index 884d829..43abd79 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -211,8 +211,8 @@ func (c *Controller) Reconcile(ctx context.Context, _ ctrlruntimereconcile.Reque c.Lock() defer c.Unlock() - c.logger.Info("reconciling state of the world started") - defer c.logger.Info("reconciling state of the world finished") + c.logger.V(1).Info("reading state of the world") + defer c.logger.V(1).Info("finished reading state of the world") store := Store{} for _, f := range c.listFuncs { @@ -255,6 +255,9 @@ func (c *Controller) delete(obj Object) { } func (c *Controller) propagate(resourceEvents []ResourceEvent) { + c.logger.V(1).Info("propagating new state of the world events", "events", len(resourceEvents)) + defer c.logger.V(1).Info("finished propagating new state of the world events") + topology, err := c.topology.Build(c.cache.List(resourceStoreId)) if err != nil { c.logger.Error(err, "error building topology") @@ -287,6 +290,9 @@ func (c *Controller) handleCacheEvent(snapshot watchable.Snapshot[string, Store] return objs } + c.logger.V(1).Info("handling new state of the world") + defer c.logger.V(1).Info("finished handling new state of the world") + newObjs := snapshot.State[resourceStoreId] events := lo.FilterMap(lo.Keys(newObjs), func(uid string, _ int) (ResourceEvent, bool) { @@ -325,6 +331,7 @@ func (c *Controller) handleCacheEvent(snapshot watchable.Snapshot[string, Store] events = append(events, deleteEvents...) if len(events) > 0 { // this condition is actually redundant; if the snapshot has updates, there must be events + c.logger.V(1).Info("state of the world has not changed") c.propagate(events) }