From 638dcd3360dd1c4a119a617e474f3f9cafdc4521 Mon Sep 17 00:00:00 2001
From: Pierre Souchay
Date: Tue, 15 Sep 2020 11:47:10 +0200
Subject: [PATCH 1/3] [BUGFIX] Avoid GetDatacenter* methods to flood Consul
servers logs
When calling `GetDatacentersByDistance()` or `GetDatacentersMap()`, an
incorrect condition was used to diplay log message, thus flooding
Consul's logs.
Example of message:
```
[WARN] agent.router: Non-server in server-only area: non_server=myClientNode area=lan
```
This message is only valid for WAN areas, filter to avoid creating
hundreds of logs/s on our clusters, each time someone is calling this
method.
Our logs were flooded by such messages when migrating our Consul servers
from 1.7.7 to 1.8.4.
This will issue fix #8663
---
agent/router/router.go | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
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
}
From 4797a9c51687833b62daa265beb8b5e4b2cf8b21 Mon Sep 17 00:00:00 2001
From: Pierre Souchay
Date: Tue, 15 Sep 2020 12:00:27 +0200
Subject: [PATCH 2/3] Added Changelog for PR #8685.
---
.changelog/8685.txt | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 .changelog/8685.txt
diff --git a/.changelog/8685.txt b/.changelog/8685.txt
new file mode 100644
index 0000000000..fae971b7b2
--- /dev/null
+++ b/.changelog/8685.txt
@@ -0,0 +1,3 @@
+```release-note:bug
+Avoid logs to be flooded with `[WARN] agent.router: Non-server in server-only area: non_server=myClientNode area=lan` [GH-8663](https://github.com/hashicorp/consul/issues/8663)
+```
From 898d8452576075d4684937069d3191de19634d4e Mon Sep 17 00:00:00 2001
From: Daniel Nephin
Date: Tue, 15 Sep 2020 17:56:06 -0400
Subject: [PATCH 3/3] Update .changelog/8685.txt
---
.changelog/8685.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.changelog/8685.txt b/.changelog/8685.txt
index fae971b7b2..17ae094bea 100644
--- a/.changelog/8685.txt
+++ b/.changelog/8685.txt
@@ -1,3 +1,3 @@
```release-note:bug
-Avoid logs to be flooded with `[WARN] agent.router: Non-server in server-only area: non_server=myClientNode area=lan` [GH-8663](https://github.com/hashicorp/consul/issues/8663)
+fixed a bug that caused logs to be flooded with `[WARN] agent.router: Non-server in server-only area`
```