fix(agent): Warn on multple agent configuration tables seen (#15402)

This commit is contained in:
Joshua Powers 2024-05-31 02:30:15 -06:00 committed by GitHub
parent 898b1c3e2c
commit 18292475fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 0 deletions

View File

@ -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! Overlapping settings in multiple agent tables are not supported: may cause undefined behavior")
})
}
c.seenAgentTable = true
subTable, ok := val.(*ast.Table)
if !ok {
return errors.New("invalid configuration, error parsing agent table")