From 3ee2aa1325b1ffaa2ab99fa5beaaa102109a08f0 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Tue, 15 Sep 2020 17:57:05 -0400 Subject: [PATCH] Merge pull request #8685 from pierresouchay/do_not_flood_logs_with_Non-server_in_server-only_area [BUGFIX] Avoid GetDatacenter* methods to flood Consul servers logs --- .changelog/8685.txt | 3 +++ agent/router/router.go | 24 ++++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 .changelog/8685.txt diff --git a/.changelog/8685.txt b/.changelog/8685.txt new file mode 100644 index 0000000000..17ae094bea --- /dev/null +++ b/.changelog/8685.txt @@ -0,0 +1,3 @@ +```release-note:bug +fixed a bug that caused logs to be flooded with `[WARN] agent.router: Non-server in server-only area` +``` diff --git a/agent/router/router.go b/agent/router/router.go index 243082a0ef..027303bea2 100644 --- a/agent/router/router.go +++ b/agent/router/router.go @@ -536,10 +536,13 @@ func (r *Router) GetDatacentersByDistance() ([]string, error) { for _, m := range info.cluster.Members() { ok, parts := metadata.IsConsulServer(m) if !ok { - r.logger.Warn("Non-server in server-only area", - "non_server", m.Name, - "area", areaID, - ) + if areaID != types.AreaLAN { + r.logger.Warn("Non-server in server-only area", + "non_server", m.Name, + "area", areaID, + "func", "GetDatacentersByDistance", + ) + } continue } @@ -547,6 +550,7 @@ func (r *Router) GetDatacentersByDistance() ([]string, error) { r.logger.Debug("server in area left, skipping", "server", m.Name, "area", areaID, + "func", "GetDatacentersByDistance", ) continue } @@ -607,10 +611,13 @@ func (r *Router) GetDatacenterMaps() ([]structs.DatacenterMap, error) { for _, m := range info.cluster.Members() { ok, parts := metadata.IsConsulServer(m) if !ok { - r.logger.Warn("Non-server in server-only area", - "non_server", m.Name, - "area", areaID, - ) + if areaID != types.AreaLAN { + r.logger.Warn("Non-server in server-only area", + "non_server", m.Name, + "area", areaID, + "func", "GetDatacenterMaps", + ) + } continue } @@ -618,6 +625,7 @@ func (r *Router) GetDatacenterMaps() ([]structs.DatacenterMap, error) { r.logger.Debug("server in area left, skipping", "server", m.Name, "area", areaID, + "func", "GetDatacenterMaps", ) continue }