dhiaayachi / consul

Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
https://www.consul.io
Other
0 stars 0 forks source link

[NET-10952] fix cluster dns lookup family to gracefully handle ipv6 #102

Open dhiaayachi opened 1 month ago

dhiaayachi commented 1 month ago

Description

When creating an envoy cluster the default DNS Lookup Family defaults to AUTO, for inter-cluster communication this is not an issue but when creating a cluster that access external sources (like we do for JWTProviders) this can cause an issue. The AUTO setting prefers using ipv6, so if a user has a cluster that is not setup to handle ipv6 they will get an ipv6 address back for the external source and will be unable to connect.

To handle this we will be using the V4_PREFERRED lookup family when STRICT_DNS is enabled (STRICT_DNS will grab all addresses for the target and attempt to make a host for each and load balance between them).

When LOGICAL_DNS is enabled (LOGICAL_DNS will grab all the addresses and only use the first when a new connection is needed) we will use the ALL lookup family, which fetches all the ip addresses for a given hostname and cycles through them to find the first one that is reachable using happy eyeballs

If any other DNS Discovery Type is used we fallback to the default of AUTO because envoy ignores the Lookup Family for all other cluster types.

Testing & Reproduction

Links

PR Checklist

dhiaayachi commented 1 month ago

Thanks for reporting this issue!

This change to the default DNS Lookup Family for clusters is a good improvement for inter-cluster communication. It ensures that connections to external sources work reliably, even when IPv6 is not available. The use of V4_PREFERRED and ALL for STRICT_DNS and LOGICAL_DNS, respectively, makes sense and will likely improve the reliability of these cluster types.

This change looks like a great improvement for Consul's handling of DNS lookups. Thank you for your work on this!