DataDog / integrations-core

Core integrations of the Datadog Agent
BSD 3-Clause "New" or "Revised" License
937 stars 1.41k forks source link

Consul integration fails to detect leader when using ipv6 #18707

Open michaz opened 1 month ago

michaz commented 1 month ago

Steps to reproduce the issue:

  1. Set up a Consul cluster where Consul binds to ipv6 addresses
  2. Enable Datadog-Consul integration

Describe the results you received: Service and catalog checks are skipped on every instance, including the leader.

Describe the results you expected: Service and catalog checks are performed on the leader.

Additional information you deem important (e.g. issue happens only occasionally): The integration seems to think that no instance is the leader. I think this is because leadership is determined by string-comparing IP addresses, and that fails on ipv6 because the address format is different between the left-hand side and the right-hand side.

And that's because the address in Member.Addr that is returned by Consul's API isn't in brackets, unlike many other ipv6 addresses returned by Consul.

Maybe there is a more robust way to find out if the local Consul node is the leader.