Add IPv6 nameserver to the internal DNS's upstreams.#47512
Add IPv6 nameserver to the internal DNS's upstreams.#47512thaJeztah merged 1 commit intomoby:masterfrom
Conversation
When configuring the internal DNS resolver - rather than keep IPv6 nameservers read from the host's resolv.conf in the container's resolv.conf, treat them like IPv4 addresses and use them as upstream resolvers. For IPv6 nameservers, if there's a zone identifier in the address or the container itself doesn't have IPv6 support, mark the upstream addresses for use in the host's network namespace. Signed-off-by: Rob Murray <[email protected]>
|
The HostLoopback rules are getting pretty complicated and subtle with this change. With the possibility for a split horizon (i.e. the same global-scope prefix routes to a container network inside the container netns, but to a physical network in the host netns) we will certainly pick incorrectly at least some of the time. And the users impacted don't have any way to overrule our heuristics. Since we're already making a user-facing change to DNS forwarding, what do you think of ripping the band-aid off and also overhauling the IPv4 forwarding behaviour in the same major release? If we could start again from scratch without any need to maintain backwards-compatibility, my ideal behaviour would be:
Note that in my ideal world, the side of the horizon custom each nameserver is resolved from is determined by the source of the address and user preference, not by any properties of the address itself. Of course, we cannot just change the DNS forwarding behaviour for all containers in the next major release without breaking some subset of users. But I think it would be possible to make that the behaviour for new containers without breaking existing containers or giving ourselves an unreasonable maintenance burden to carry. If "forward query from host vs. container netns" is an explicit per-nameserver option in the container config, we could migrate existing containers and transform container-create requests for legacy API versions to have legacy forwarding behaviour by applying the existing rules. As for legacy containers without DNS overrides, it might be okay to unconditionally resolve nameservers loaded from the host's resolv.conf in the host's netns. Anyone relying on host resolv.conf nameservers being resolved from the container's netns is depending on really subtle and brittle behaviour. Anyone intentionally depending on such behaviour could simply work around the breaking change by overriding the nameservers in the container config. Otherwise, we could make it so that legacy containers see no breaking changes at all by extending the container config with an option to use the legacy "only resolve loopback addresses from resolv.conf in the host netns" behaviour which is implicitly enabled on migrated containers and containers created with legacy API versions. |
neersighted
left a comment
There was a problem hiding this comment.
This change actually simplifies the semantics around proxyDNS, and the tests are quite straightforward.
LGTM; I am in favor of reconsidering the DNS semantics, but at the same time I think we can open a follow-up issue to do so.
corhere
left a comment
There was a problem hiding this comment.
I had confused myself into thinking incorrectly that the HostLoopback heuristics were also applied to user-configured DNS overrides. LGTM.
- What I did
When configuring the internal DNS resolver - rather than keep IPv6 nameservers read from the host's resolv.conf in the container's resolv.conf, treat them like IPv4 addresses and use them as upstream resolvers.
Fixes #46329
- How I did it
For IPv6 nameservers, if there's a zone identifier in the address or the container itself doesn't have IPv6 support, mark the upstream addresses for use in the host's network namespace.
- How to verify it
Updated unit tests.
I gather our test hosts don't have IPv6, so I don't think we can have an integration test with an IPv6 upstream resolver (?).
On an Ubuntu VM ...
With the host's
resolv.conflisting one of Google's IPv6 nameservers - before this change, the IPv6 nameserver ends up in the container'sresolv.confalong with the internal resolver ...With the change, the upstream IPv6 server is listed as an "ExtServer" ...
When the host's
resolv.confhas a zone-id in the nameserver's address, the ExtServer is listed with thehostmarker, meaning the upstream request will happen in the host's namespace ...When the container has IPv6 disabled, the IPv6 ExtServer is still used - but from the host's namespace ...
- Description for the changelog