-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(dns): Support alt domains #5940
feat(dns): Support alt domains #5940
Conversation
Add flags for `alt-domain`, and configuration for `alt_domains`.
Support `alt_domains` in `handleQuery` and `resolveCNAME`.
Thanks for the PR @akshayganeshen! At first glance it seems like one of the new tests is consistently failing in CI: TestDNS_AltDomains_Overlap Is this test passing locally? |
Hey @freddygv, that test does not pass locally. It's an example of the sort of edge-cases that my implementation does not handle:
Without that test, I think it fulfills the desired use-case, but this edge-case should have a well-defined expectation. I believe it can be resolved in two ways:
I was hoping to get some feedback before assuming which was the desired solution, or if there's another solution entirely that I'm missing. |
Change `alt_domains` from a string-list to a single string. Revert changes to loop over all domains in DNS dispatch. Handle ambiguous matches by taking the longer matching domain/suffix.
I've updated the implementation to use only a single Did I miss something there? Or is this as expected? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the changes! This PR looks pretty good now! I found another small thing and it would be also great if you could add the flag and the config option to website/source/docs/agent/options.html.md. 🙏 👍
We are still discussing internally what to do with the issue, when the datacenter is part of the domain.
@akshayganeshen: Thank you so much for working on this. My personal thought for ambiguous domains is that the primary domain as opposed to the alternative one should be used. I had not thought of this case when originally writing my branch. A second option is to keep a list of the available datacenters to check a potential datacenter. I can see a risk where not preferring the previous behavior can cause easily missed issues where a service suddenly fails to discover services that it expected to find in a remote datacenter. |
@akshayganeshen @clly I think we found a solution for the ambiguous domains. I suggest we are validating the altDomain in This validation should also make Thanks again, for bearing with us! |
@i0rek @clly Thanks for the tips! I'll do the validation in (I'll also update the docs appropriately.) |
Validate `alt_domain` when building runtime config. Prevents situations where domain resolution is ambiguous.
Update to account for config check that disallows ambiguous domains. Still demonstrate that this successfully resolves overlapping domains.
I've updated the implementation and the tests pass! I'm still updating the documentation though. I'll also add a test case for the invalid config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, everything seems to work perfectly! Thanks for bearing with us!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, the test failures are relevant: https://travis-ci.org/hashicorp/consul/jobs/546001060#L1294. You have to add DNSAltDomain
in these places: https://github.com/akshayganeshen/consul/blob/d7bf494f042800cdcec60d5dcbb6574c4a4a9595/agent/config/runtime_test.go#L5153 and https://github.com/akshayganeshen/consul/blob/d7bf494f042800cdcec60d5dcbb6574c4a4a9595/agent/config/runtime_test.go#L2950.
Good catch. Will fix. |
@akshayganeshen given that we have a release coming up shortly, I went ahead and made the remaining finishing touches to your PR. I hope you don't mind us carrying the PR across the finish line. We appreciate your contribution! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
@freddygv @i0rek thank you both! 🙏 Sorry I couldn't get around to this sooner. |
Alternate DNS domains are supplied with the
-alt-domain
flag oralt_domains
configuration parameter.The DNS resolver will attempt to parse and match each domain during resolution.
See #4165 for use-case.