From c39ff8e6f8d91f763908dab19e94e78a2ec92c03 Mon Sep 17 00:00:00 2001 From: David Collom Date: Wed, 18 Sep 2024 12:15:09 +0100 Subject: [PATCH 1/2] Fix Logging issue where %s is presented but `Event` doesn't format the string. Signed-off-by: David Collom --- internal/controller/sync.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/controller/sync.go b/internal/controller/sync.go index 5f8f7a2..24f76f4 100644 --- a/internal/controller/sync.go +++ b/internal/controller/sync.go @@ -107,7 +107,7 @@ func (r *Route) sync(ctx context.Context, req reconcile.Request, route *routev1. if err != nil { return result, err } - r.eventRecorder.Event(route, corev1.EventTypeNormal, ReasonIssuing, "Created new CertificateRequest for Route %s") + r.eventRecorder.Event(route, corev1.EventTypeNormal, ReasonIssuing, "Created new CertificateRequest") return result, nil } // is the CR Ready and Approved? From 5fcfc47612f3ffc3bcb5b00c36d660640f99459d Mon Sep 17 00:00:00 2001 From: David Collom Date: Wed, 18 Sep 2024 13:20:30 +0000 Subject: [PATCH 2/2] Fixing Logging entries to better follow structured logging practises. Signed-off-by: David Collom --- internal/controller/controller.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/controller/controller.go b/internal/controller/controller.go index 005a80b..7215706 100644 --- a/internal/controller/controller.go +++ b/internal/controller/controller.go @@ -54,12 +54,12 @@ func shouldSync(log logr.Logger, route *routev1.Route) bool { } if metav1.HasAnnotation(route.ObjectMeta, cmapi.IssuerNameAnnotationKey) { - log.V(5).Info("Route has the annotation %s=%s", cmapi.IssuerNameAnnotationKey, route.Annotations[cmapi.IssuerNameAnnotationKey]) + log.V(5).Info("Route has the annotation", "annotation-key", cmapi.IssuerNameAnnotationKey, "annotation-value", route.Annotations[cmapi.IssuerNameAnnotationKey]) return true } if metav1.HasAnnotation(route.ObjectMeta, cmapi.IngressIssuerNameAnnotationKey) { - log.V(5).Info("Route has the annotation %s=%s", cmapi.IngressIssuerNameAnnotationKey, route.Annotations[cmapi.IngressIssuerNameAnnotationKey]) + log.V(5).Info("Route has the annotation", "annotation-key", cmapi.IngressIssuerNameAnnotationKey, "annotation-value", route.Annotations[cmapi.IngressIssuerNameAnnotationKey]) return true }