-
Notifications
You must be signed in to change notification settings - Fork 5.5k
dynamic_forward_proxy: adding dns_resolvers to dns_cache used by the proxy filter #16294
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
Changes from 5 commits
c152c7e
9fa85a7
3988eb0
026ca82
6260b09
9d95c7b
5501231
d3aaa31
a673969
c03697b
7d41f09
0677cf9
2feca06
54af3ba
9390e7a
5c1ae91
04cc847
a9a03bc
be652e9
6be5d06
6d4aa65
6e99c81
b67d82e
2d7e299
e689756
25e4ae0
9d2d403
e9c44c7
7c44cc6
0602d8d
6af2490
4e2a6e8
3b41679
f9a8326
6234826
364258f
e91e5e0
8060ed8
58c0500
94c5bd3
19201c5
8a7d214
6a3f7e5
e0f0df2
5eef9b3
80b95ea
0412e3a
69345fe
e83289a
004177f
aaaea99
ecd3229
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ syntax = "proto3"; | |
| package envoy.extensions.common.dynamic_forward_proxy.v3; | ||
|
|
||
| import "envoy/config/cluster/v3/cluster.proto"; | ||
| import "envoy/config/core/v3/address.proto"; | ||
|
|
||
| import "google/protobuf/duration.proto"; | ||
| import "google/protobuf/wrappers.proto"; | ||
|
|
@@ -27,7 +28,7 @@ message DnsCacheCircuitBreakers { | |
|
|
||
| // Configuration for the dynamic forward proxy DNS cache. See the :ref:`architecture overview | ||
| // <arch_overview_http_dynamic_forward_proxy>` for more information. | ||
| // [#next-free-field: 9] | ||
| // [#next-free-field: 10] | ||
| message DnsCacheConfig { | ||
| option (udpa.annotations.versioning).previous_message_type = | ||
| "envoy.config.common.dynamic_forward_proxy.v2alpha.DnsCacheConfig"; | ||
|
|
@@ -101,4 +102,13 @@ message DnsCacheConfig { | |
| // ``envoy.restart_features.use_apple_api_for_dns_lookups`` runtime value is true during | ||
| // server startup. Apple' API only uses UDP for DNS resolution. | ||
| bool use_tcp_for_dns_lookups = 8; | ||
|
|
||
| // If DNS resolvers are specified, | ||
| // DNS cache will perform DNS resolution via those resolvers. | ||
| // Setting this value causes failure if the | ||
| // ``envoy.restart_features.use_apple_api_for_dns_lookups`` runtime value is true during | ||
| // server startup. Apple's API only allows overriding DNS resolvers via system settings. | ||
| // If this setting is not specified, the value defaults to the default | ||
| // resolver, which uses /etc/resolv.conf for configuration. | ||
| repeated config.core.v3.Address dns_resolvers = 9; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this relate to #16237? Should this be a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for letting me know about this change. Looks like we're going to have @suniltheta How do you feel about the above changes?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for letting me know about this PR. Just recently committed all of the changes for the PR #16237. A new protobuf message
Having said that if we move resolvers inside I lean towards keeping the resolvers (repeated Address type) out of dedicated
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I would separate
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So is this the format of the protobuf message that is being proposed? FORMAT A: After the merge of #16237 we do Instead we would be doing
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, fair point. Let's go with #16294 (comment) then.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @htuch What's the next step? @suniltheta and I discussed merging this PR as it is and make another PR to add the new
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we're planning on immediately restructuring in the next PR that isn't so great. Can we at least introduce the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am on board with this idea as well. We can place the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
|
|
||
| #include "common/config/utility.h" | ||
| #include "common/http/utility.h" | ||
| #include "common/network/resolver_impl.h" | ||
| #include "common/network/utility.h" | ||
|
|
||
| // TODO(mattklein123): Move DNS family helpers to a smaller include. | ||
|
|
@@ -20,8 +21,8 @@ DnsCacheImpl::DnsCacheImpl( | |
| const envoy::extensions::common::dynamic_forward_proxy::v3::DnsCacheConfig& config) | ||
| : main_thread_dispatcher_(main_thread_dispatcher), | ||
| dns_lookup_family_(Upstream::getDnsLookupFamilyFromEnum(config.dns_lookup_family())), | ||
| resolver_(main_thread_dispatcher.createDnsResolver({}, config.use_tcp_for_dns_lookups())), | ||
| tls_slot_(tls), scope_(root_scope.createScope(fmt::format("dns_cache.{}.", config.name()))), | ||
| resolver_(selectDnsResolver(config, main_thread_dispatcher)), tls_slot_(tls), | ||
| scope_(root_scope.createScope(fmt::format("dns_cache.{}.", config.name()))), | ||
| stats_(generateDnsCacheStats(*scope_)), | ||
| resource_manager_(*scope_, loader, config.name(), config.dns_cache_circuit_breaker()), | ||
| refresh_interval_(PROTOBUF_GET_MS_OR_DEFAULT(config, dns_refresh_rate, 60000)), | ||
|
|
@@ -46,6 +47,23 @@ DnsCacheImpl::~DnsCacheImpl() { | |
| } | ||
| } | ||
|
|
||
| Network::DnsResolverSharedPtr DnsCacheImpl::selectDnsResolver( | ||
| const envoy::extensions::common::dynamic_forward_proxy::v3::DnsCacheConfig& config, | ||
| Event::Dispatcher& main_thread_dispatcher) { | ||
| if (!config.dns_resolvers().empty()) { | ||
| const auto& resolver_addrs = config.dns_resolvers(); | ||
| std::vector<Network::Address::InstanceConstSharedPtr> resolvers; | ||
| resolvers.reserve(resolver_addrs.size()); | ||
| for (const auto& resolver_addr : resolver_addrs) { | ||
| resolvers.push_back(Network::Address::resolveProtoAddress(resolver_addr)); | ||
| } | ||
| const bool use_tcp_for_dns_lookups = config.use_tcp_for_dns_lookups(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can pass directly to the parameter.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @adisuissa, since the PR #16237 will follow this PR(16294) shortly, this line will be replaced by using |
||
| return main_thread_dispatcher.createDnsResolver(resolvers, use_tcp_for_dns_lookups); | ||
| } | ||
|
|
||
| return main_thread_dispatcher.createDnsResolver({}, config.use_tcp_for_dns_lookups()); | ||
| } | ||
|
|
||
| DnsCacheStats DnsCacheImpl::generateDnsCacheStats(Stats::Scope& scope) { | ||
| return {ALL_DNS_CACHE_STATS(POOL_COUNTER(scope), POOL_GAUGE(scope))}; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.