c-ares: move dns shared resolver logic to upstream cluster - #46657
Open
andy-fong wants to merge 1 commit into
Open
c-ares: move dns shared resolver logic to upstream cluster#46657andy-fong wants to merge 1 commit into
andy-fong wants to merge 1 commit into
Conversation
Signed-off-by: Andy Fong <andy.fong@solo.io>
This was referenced Aug 11, 2026
Contributor
Author
|
test failure is unrelated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Commit Message: c-ares: move dns shared resolver logic to upstream cluster
Additional Description:
In #45073 I added qcache_max_ttl for the c-ares resolver and shared the resolver across clusters with identical c-ares configs so the query cache is shared. However, I didn't realize the UDP DNS filter also calls CaresDnsResolverFactory::createDnsResolver() directly, once per worker thread with that worker's dispatcher. Two workers with the same config would share a resolver bound to the wrong dispatcher, causing c-ares callbacks to fire on the wrong event loop.
Instead of adding a mutex and keying on dispatcher identity, I moved the sharing logic into the upstream cluster layer. The new
ClusterDnsResolverCacheis owned by ProdClusterManagerFactory (one per server, main thread only), so createDnsResolver() callers like the DNS filter are unaffected and always get their own resolver.Other notes:
TypedExtensionConfiglevel rather than on the unpacked c-ares config.envoy.restart_features.shared_cares_dns_resolverto false by default for now.Also related to #46577
AI Disclosure: this PR is mostly generated by AI with just a few hand edit and updates. I did iterated several times with AI to come up with this solution and understand all the changes.
Risk Level: low
Testing: Added unit tests and also manually tested with tcpdump and the shared resolver feature on and off to confirm the query cache is working to reduce dns lookup to the server.
Docs Changes:
Release Notes: Fixed race caused by shared c-ares dns resolvers.
Platform Specific Features:
[Optional Runtime guard:] "envoy.restart_features.shared_cares_dns_resolver" is set to false by default now