Skip to content

Commit

Permalink
Merge pull request Kuadrant#46 from Kuadrant/reconciliation-logs
Browse files Browse the repository at this point in the history
controller: debug logging
  • Loading branch information
guicassolato authored Oct 25, 2024
2 parents 66e1e50 + 58dcbb2 commit d33de83
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit d33de83

Please sign in to comment.