Skip to content

Commit ae7f0ed

Browse files
committed
operator: Log canonical cluster names and reduce syncer verbosity
Replace raw internal cluster identifiers with CanonicalClusterName() in lifecycle log lines so they show human-readable names (e.g. "first") instead of empty string. Demote SyncAll cluster list log from Info to Debug and per-syncer call details from Info to Trace to reduce noise at default log levels. Switch the syncer log from a sprintf'd message to structured key-value pairs.
1 parent 45266ab commit ae7f0ed

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

operator/internal/lifecycle/client.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,17 @@ func (r *ResourceClient[T, U]) syncer(ctx context.Context, owner U, clusterName
278278
func (r *ResourceClient[T, U]) SyncAll(ctx context.Context, owner U) error {
279279
var syncErr error
280280
logger := log.FromContext(ctx).WithName("SyncAll")
281-
clusterList := r.clusterList(owner)
282-
logger.V(log.InfoLevel).Info("syncing all clusters", "clusterList", clusterList)
281+
var canonicalClusterList []string
283282
for _, clusterName := range r.clusterList(owner) {
284-
msg := fmt.Sprintf("syncer called, clusterName=%q, owner.Name=%q owner.UID=%q owner.GroupVersionKind=%q", clusterName, owner.GetName(), owner.GetUID(), owner.GetObjectKind().GroupVersionKind().String())
285-
logger.V(log.InfoLevel).Info(msg)
283+
canonicalClusterList = append(canonicalClusterList, CanonicalClusterName(clusterName, r.manager))
284+
}
285+
logger.V(log.DebugLevel).Info("syncing all clusters", "clusterList", canonicalClusterList)
286+
for _, clusterName := range r.clusterList(owner) {
287+
logger.V(log.TraceLevel).Info("syncer called",
288+
"clusterName", CanonicalClusterName(clusterName, r.manager),
289+
"ownerName", owner.GetName(),
290+
"ownerUID", owner.GetUID(),
291+
"ownerGroupVersionKind", owner.GetObjectKind().GroupVersionKind().String())
286292
syncer, err := r.syncer(ctx, owner, clusterName)
287293
if err != nil {
288294
return err
@@ -300,6 +306,7 @@ func (r *ResourceClient[T, U]) SyncAll(ctx context.Context, owner U) error {
300306
// a tracker that can be used for determining necessary operations on the pools.
301307
func (r *ResourceClient[T, U]) FetchExistingAndDesiredPools(ctx context.Context, cluster U, configVersion string) (*PoolTracker, error) {
302308
pools := NewPoolTracker(cluster.GetGeneration())
309+
logger := log.FromContext(ctx)
303310
for _, clusterName := range r.clusterList(cluster) {
304311
existingPools, err := r.fetchExistingPools(ctx, cluster, clusterName)
305312
if err != nil {
@@ -328,14 +335,14 @@ func (r *ResourceClient[T, U]) FetchExistingAndDesiredPools(ctx context.Context,
328335
set.Spec.Template.Labels = setConfigVersionLabels(set.Spec.Template.Labels, configVersion)
329336
}
330337
}
331-
log.FromContext(ctx).V(log.DebugLevel).Info(fmt.Sprintf("found [%d] existing pools in cluster %s", len(existingPools), clusterName))
332-
log.FromContext(ctx).V(log.DebugLevel).Info(fmt.Sprintf("found [%d] desired pools in cluster %s", len(wrapped), clusterName))
338+
logger.V(log.DebugLevel).Info(fmt.Sprintf("found [%d] existing pools in cluster %s", len(existingPools), clusterName))
339+
logger.V(log.DebugLevel).Info(fmt.Sprintf("found [%d] desired pools in cluster %s", len(wrapped), clusterName))
333340

334341
pools.addExisting(existingPools...)
335342
pools.addDesired(wrapped...)
336343
}
337-
log.FromContext(ctx).V(log.DebugLevel).Info(fmt.Sprintf("found [%d] existing pools in all clusters", len(pools.existingPools)))
338-
log.FromContext(ctx).V(log.DebugLevel).Info(fmt.Sprintf("found [%d] desired pools in all clusters", len(pools.desiredPools)))
344+
logger.V(log.DebugLevel).Info(fmt.Sprintf("found [%d] existing pools in all clusters", len(pools.existingPools)))
345+
logger.V(log.DebugLevel).Info(fmt.Sprintf("found [%d] desired pools in all clusters", len(pools.desiredPools)))
339346

340347
return pools, nil
341348
}

0 commit comments

Comments
 (0)