From bc15fcbffe3efb7dee7488c65087974296fa39be Mon Sep 17 00:00:00 2001 From: zirain Date: Sun, 15 Jun 2025 20:51:25 +0800 Subject: [PATCH 1/2] chore: make log output consistent Signed-off-by: zirain --- internal/provider/kubernetes/status_updater.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/provider/kubernetes/status_updater.go b/internal/provider/kubernetes/status_updater.go index c8b0472953..1ad394ff13 100644 --- a/internal/provider/kubernetes/status_updater.go +++ b/internal/provider/kubernetes/status_updater.go @@ -104,9 +104,8 @@ func (u *UpdateHandler) apply(update Update) { newObj := update.Mutator.Mutate(obj) if isStatusEqual(obj, newObj) { - u.log.WithName(update.NamespacedName.Name). - WithName(update.NamespacedName.Namespace). - Info("status unchanged, bypassing update") + u.log.Info("status unchanged, bypassing update", "name", update.NamespacedName.Name, + "namespace", update.NamespacedName.Namespace) statusUpdateTotal.WithStatus(statusNoAction, kindLabel.Value(objKind)).Increment() return nil From d1dfb833a9cef4f01a36d9d2b7913537d62330c0 Mon Sep 17 00:00:00 2001 From: zirain Date: Sun, 15 Jun 2025 21:01:12 +0800 Subject: [PATCH 2/2] update Signed-off-by: zirain --- internal/provider/kubernetes/status_updater.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/provider/kubernetes/status_updater.go b/internal/provider/kubernetes/status_updater.go index 1ad394ff13..80a78905bb 100644 --- a/internal/provider/kubernetes/status_updater.go +++ b/internal/provider/kubernetes/status_updater.go @@ -80,7 +80,8 @@ func (u *UpdateHandler) apply(update Update) { obj = update.Resource objKind = KindOf(obj) ) - + log := u.log.WithValues("name", update.NamespacedName.Name, + "namespace", update.NamespacedName.Namespace, "kind", objKind) defer func() { updateDuration := time.Since(startTime) statusUpdateDurationSeconds.With(kindLabel.Value(objKind)).Record(updateDuration.Seconds()) @@ -104,8 +105,7 @@ func (u *UpdateHandler) apply(update Update) { newObj := update.Mutator.Mutate(obj) if isStatusEqual(obj, newObj) { - u.log.Info("status unchanged, bypassing update", "name", update.NamespacedName.Name, - "namespace", update.NamespacedName.Namespace) + log.Info("status unchanged, bypassing update") statusUpdateTotal.WithStatus(statusNoAction, kindLabel.Value(objKind)).Increment() return nil @@ -115,8 +115,7 @@ func (u *UpdateHandler) apply(update Update) { return u.client.Status().Update(context.Background(), newObj) }); err != nil { - u.log.Error(err, "unable to update status", "name", update.NamespacedName.Name, - "namespace", update.NamespacedName.Namespace) + log.Error(err, "unable to update status") statusUpdateTotal.WithFailure(metrics.ReasonError, kindLabel.Value(objKind)).Increment() } else { @@ -142,7 +141,7 @@ func (u *UpdateHandler) Start(ctx context.Context) error { return nil case update := <-u.updateChannel: u.log.Info("received a status update", "namespace", update.NamespacedName.Namespace, - "name", update.NamespacedName.Name) + "name", update.NamespacedName.Name, "kind", KindOf(update.Resource)) u.apply(update) }