From 773d57ee029105e2c57d4163255fff7789752cbc Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Sat, 6 Jun 2026 21:33:52 +0600 Subject: [PATCH] plan, controller: drop noisy INFO endpoint dumps; use ErrorS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit createAndApplyPlan logged the entire desired/current endpoint slices at INFO every reconcile. At any non-trivial zone size this is large, unstructured, and includes target IPs we don't need in steady-state operator logs. Emit a structured one-line summary at V(2) with counts, and keep the full dump at V(4) for debugging. Same file: replace klog.Error(err.Error()) and klog.Errorln(err) with klog.ErrorS so the structured logger gets a real "err" field instead of stringified output, and add a short message for each failure site. In the controller, klog.Error("failed to build controller.", err.Error()) was passing two args to a function that takes variadic interfaces — losing the structured "err" field. Switch to klog.ErrorS. Signed-off-by: Tamal Saha --- .../external-dns/externaldns_controller.go | 2 +- pkg/plan/plan.go | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/controllers/external-dns/externaldns_controller.go b/pkg/controllers/external-dns/externaldns_controller.go index 076e41fb..1329c2fa 100644 --- a/pkg/controllers/external-dns/externaldns_controller.go +++ b/pkg/controllers/external-dns/externaldns_controller.go @@ -280,7 +280,7 @@ func (r *ExternalDNSReconciler) SetupWithManager(mgr ctrl.Manager) error { Watches(&core.Secret{}, secretToEdns). Build(r) if err != nil { - klog.Error("failed to build controller.", err.Error()) + klog.ErrorS(err, "failed to build controller") return err } diff --git a/pkg/plan/plan.go b/pkg/plan/plan.go index 077c7954..f3354ac3 100644 --- a/pkg/plan/plan.go +++ b/pkg/plan/plan.go @@ -263,7 +263,7 @@ func SetDNSRecords(ctx context.Context, edns *api.ExternalDNS) ([]api.DNSRecord, endpointsSource, err := createEndpointsSource(ctx, cfg) if err != nil { - klog.Error(err.Error()) + klog.ErrorS(err, "failed to create endpoints source") return nil, err } @@ -271,19 +271,19 @@ func SetDNSRecords(ctx context.Context, edns *api.ExternalDNS) ([]api.DNSRecord, pvdr, err := buildProvider(ctx, cfg, domainFilter) if err != nil { - klog.Error(err.Error()) + klog.ErrorS(err, "failed to build provider") return nil, err } reg, err := createRegistry(cfg, pvdr) if err != nil { - klog.Errorln(err) + klog.ErrorS(err, "failed to create registry") return nil, err } dnsRecs, err := createAndApplyPlan(ctx, cfg, reg, endpointsSource, domainFilter) if err != nil { - klog.Errorln(err) + klog.ErrorS(err, "failed to apply plan") return nil, err } @@ -389,8 +389,8 @@ func createAndApplyPlan(ctx context.Context, cfg *externaldns.Config, r registry } pln = pln.Calculate() - klog.Info("Desired: ", pln.Desired) - klog.Info("Current: ", pln.Current) + klog.V(2).InfoS("plan computed", "desired", len(pln.Desired), "current", len(pln.Current)) + klog.V(4).InfoS("plan endpoints", "desired", pln.Desired, "current", pln.Current) dnsRecs := make([]api.DNSRecord, 0) @@ -402,7 +402,7 @@ func createAndApplyPlan(ctx context.Context, cfg *externaldns.Config, r registry if pln.Changes.HasChanges() { err = r.ApplyChanges(ctx, pln.Changes) if err != nil { - klog.Error(err.Error()) + klog.ErrorS(err, "failed to apply changes") return nil, err } klog.Info("plan applied")