From 1a76fade5092ac54bcf20f97525ed2bdd88fa7d2 Mon Sep 17 00:00:00 2001 From: Josh Powers Date: Fri, 24 May 2024 13:20:17 -0600 Subject: [PATCH 1/2] fix(agent): Warn on multple agent configuration tables seen --- config/config.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/config/config.go b/config/config.go index 86376577ea119..b2013f7752226 100644 --- a/config/config.go +++ b/config/config.go @@ -94,6 +94,9 @@ type Config struct { Persister *persister.Persister NumberSecrets uint64 + + seenAgentTable bool + seenAgentTableOnce sync.Once } // Ordered plugins used to keep the order in which they appear in a file @@ -516,6 +519,13 @@ func (c *Config) LoadConfigData(data []byte) error { // Parse agent table: if val, ok := tbl.Fields["agent"]; ok { + if c.seenAgentTable { + c.seenAgentTableOnce.Do(func() { + log.Printf("W! Multiple agent tables are not supported: undefined behavior when multiple are present") + }) + } + c.seenAgentTable = true + subTable, ok := val.(*ast.Table) if !ok { return errors.New("invalid configuration, error parsing agent table") From 50d477824e6711ad39988c5c56a991a7f50b83d4 Mon Sep 17 00:00:00 2001 From: Joshua Powers Date: Wed, 29 May 2024 13:41:02 -0600 Subject: [PATCH 2/2] Apply suggestions from code review --- config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index b2013f7752226..885d7d1e916b2 100644 --- a/config/config.go +++ b/config/config.go @@ -521,7 +521,7 @@ func (c *Config) LoadConfigData(data []byte) error { if val, ok := tbl.Fields["agent"]; ok { if c.seenAgentTable { c.seenAgentTableOnce.Do(func() { - log.Printf("W! Multiple agent tables are not supported: undefined behavior when multiple are present") + log.Printf("W! Overlapping settings in multiple agent tables are not supported: may cause undefined behavior") }) } c.seenAgentTable = true