fix(agent): Warn on multple agent configuration tables seen (#15402)
This commit is contained in:
parent
898b1c3e2c
commit
18292475fd
|
|
@ -94,6 +94,9 @@ type Config struct {
|
||||||
Persister *persister.Persister
|
Persister *persister.Persister
|
||||||
|
|
||||||
NumberSecrets uint64
|
NumberSecrets uint64
|
||||||
|
|
||||||
|
seenAgentTable bool
|
||||||
|
seenAgentTableOnce sync.Once
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ordered plugins used to keep the order in which they appear in a file
|
// 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:
|
// Parse agent table:
|
||||||
if val, ok := tbl.Fields["agent"]; ok {
|
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)
|
subTable, ok := val.(*ast.Table)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("invalid configuration, error parsing agent table")
|
return errors.New("invalid configuration, error parsing agent table")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue