[BUG] NDM Autodisovery in datadog.yaml
breaks when using ignored_ip_addresses
#30181
Labels
datadog.yaml
breaks when using ignored_ip_addresses
#30181
Agent Environment
Tested Versions: 7.57.2 & 7.57.0
Bug was introduced in
7.54.0
whennetwork_devices.autodiscovery
was added todatadog.yaml
Describe what happened:
When using the
ignored_ip_addresses
feature ofnetwork_devices.autodiscovery.configs
, the SNMP Listener will fail to start and no network devices will be monitored.Describe what you expected:
Expect
ignored_ip_addresses
to work as documented.Steps to reproduce the issue:
Add a
network_devices
config todatadog.yaml
:No log for
Configs for autodiscovery detected: Adding the snmp listener
orsnmp listener successfully started
inagent.log
Additional environment details (Operating System, Cloud provider, etc):
Here is a PR with a unit test showing the failure: #30177
Here is a PR with a fix and a new unit test: #30180
The issue comes down to the YAML Unmarshal. It is documented that the config item
ignored_ip_addresses
should be a list of IPs as strings, but the struct for the config expects amap[string]bool
. In the primary autodiscovery code, it callssnmp.NewListenerConfig()
https://github.com/DataDog/datadog-agent/blob/main/comp/core/autodiscovery/listeners/snmp.go#L71
Which has a special hook for converting lists to maps:
https://github.com/DataDog/datadog-agent/blob/main/pkg/snmp/snmp.go#L101-L117
But, when the agent starts and tries to add the listener, it attempts to load the config without this hook, and as such the configuration fails to load and the listener is not added. The error is also not logged, so the user has no idea why it's failing:
datadog-agent/pkg/config/autodiscovery/autodiscovery.go
Lines 77 to 84 in 122c53f
The text was updated successfully, but these errors were encountered: