dns: disable the use of search namespaces when using the c-ares resolver#16237
dns: disable the use of search namespaces when using the c-ares resolver#16237mattklein123 merged 18 commits intoenvoyproxy:mainfrom
Conversation
…of search namespaces when using the c-ares resolver and reconcile DNS options in a single message Signed-off-by: Sunil Narasimhamurthy <sunnrs@amazon.com>
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
|
Hi, this is a draft PR to address the issue #12432 . Also need consensus on this change where use_tcp_for_dns_lookups option will be deprecated and will be moved inside new protobuf message DnsLookupOptions.
Also @rshriram please let me know if you have any suggestion on this PR. Thank you. |
Signed-off-by: Sunil Narasimhamurthy <sunnrs@amazon.com>
api/envoy/config/core/v3/base.proto
Outdated
| } | ||
|
|
||
| // Configuration of DNS Lookup option flags which control the behavior of the DNS resolver. | ||
| message DnsLookupOptions { |
There was a problem hiding this comment.
FWIW I think we are heading towards a model of pluggable DNS resolvers in the not too distant future. I wonder if the DNS lookup options should reflect that?
There was a problem hiding this comment.
Yes, good idea. I never thought of that. Thank you for your suggestion. I will keep this in mind and take care of it in upcoming commits.
adisuissa
left a comment
There was a problem hiding this comment.
Thanks for working on this. I've added a few comments.
| // ``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; | ||
| bool use_tcp_for_dns_lookups = 8 |
There was a problem hiding this comment.
Can you add to the comment a reference to the configuration that should be used (instead of the deprecated one)?
There was a problem hiding this comment.
Added the comment.
api/envoy/config/core/v3/base.proto
Outdated
| google.protobuf.BoolValue use_tcp_for_dns_lookups = 1; | ||
|
|
||
| // Do not use the default search domains; only query hostnames as-is or as aliases. | ||
| google.protobuf.BoolValue no_defalt_search_domain = 2; |
There was a problem hiding this comment.
| google.protobuf.BoolValue no_defalt_search_domain = 2; | |
| google.protobuf.BoolValue no_default_search_domain = 2; |
There was a problem hiding this comment.
Took care of this manually. thanks for noticing.
api/envoy/config/core/v3/base.proto
Outdated
| // specified. | ||
| // Setting this value causes failure if the | ||
| // ``envoy.restart_features.use_apple_api_for_dns_lookups`` runtime value is true during | ||
| // server startup. Apple' API only uses UDP for DNS resolution. |
There was a problem hiding this comment.
| // server startup. Apple' API only uses UDP for DNS resolution. | |
| // server startup. Apple's API only uses UDP for DNS resolution. |
There was a problem hiding this comment.
Took care of this manually. thanks for noticing.
009f522 to
5862a19
Compare
…dressed few review comments Signed-off-by: Sunil Narasimhamurthy <sunnrs@amazon.com>
adisuissa
left a comment
There was a problem hiding this comment.
Looks good.
Please fix link issues, as it blocks CI.
| // server startup. Apple' API only uses UDP for DNS resolution. | ||
| bool use_tcp_for_dns_lookups = 20; | ||
| // This field is deprecated. Instead use | ||
| // :ref:`dns_lookup_options <envoy_api_field_config.config.bootstrap.v3.Bootstrap.dns_lookup_options>` |
There was a problem hiding this comment.
I think there's a wrong link here. Should probably be:
envoy_api_field_config.bootstrap.v3.Bootstrap.dns_lookup_options.
Please fix here and in other places.
There was a problem hiding this comment.
Thanks for taking a look. I am working on these changes on the side. I will try to push rest of the changes by tomorrow. I will fix this :ref: link as well.
api/envoy/config/core/v3/base.proto
Outdated
| // server startup. Apple's API only uses UDP for DNS resolution. | ||
| google.protobuf.BoolValue use_tcp_for_dns_lookups = 1; | ||
|
|
||
| // Do not use the default search domains; only query hostnames as-is or as aliases. |
There was a problem hiding this comment.
Also I think this should be tagged with [#not-implemented-hide:], because IIUC it is not implemented yet.
There was a problem hiding this comment.
All the changes are committed.
api/envoy/config/core/v3/base.proto
Outdated
| // specified. | ||
| // 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 uses UDP for DNS resolution. |
There was a problem hiding this comment.
@htuch this new message replaces a deprecated field (use_tcp_for_dns_lookups). However, it also modifies the field type from bool to google.protobuf.BoolValue.
I'm assuming it is ok, as the other field is deprecated, just want your opinion on this.
There was a problem hiding this comment.
I think this is fine. What is the default value for this field? BoolValue is mostly useful when we anticipate wanting to change the default (in particular for security related fields).
There was a problem hiding this comment.
The default value is protobuf's bool default value (false).
Actually, the name of the field use_tcp_for_dns_lookups implies it is meant to be "enabled". I'm not certain what's the added value of BoolValue in this case.
There was a problem hiding this comment.
So here is my approach to keep supporting the deprecated field "bool use_tcp_for_dns_lookups". I would love to get your opinions on them.
Even though the field "bool use_tcp_for_dns_lookups" is marked deprecated, we expect previous implementations of xDSv3 control plane to still set this value. So the logic will check if the new field "google.protobuf.BoolValue use_tcp_for_dns_lookups" is being set via dns_lookup_options or not. The code will rely on has_use_tcp_for_dns_lookups() to check if this value is being programmed by the server. If this dns_lookup_options.has_use_tcp_for_dns_lookups() is false (which means value is not set) then the code will check if the deprecated field bool use_tcp_for_dns_lookups has the value true and uses it. This makes sure of the backward compatibility of the changes.
Correct me if I am wrong here, by just using bool field type we will not be able to know if the config (true or false) is applied or not.
One might ask can we just do OR of bool use_tcp_for_dns_lookups and dns_lookup_options.use_tcp_for_dns_lookups().value(), like -> config.dns_lookup_options.use_tcp_for_dns_lookups().value() || config.use_tcp_for_dns_lookups. But as per the logic which is being worked upon now, the new field
google.protobuf.BoolValue dns_lookup_options.use_tcp_for_dns_lookups will get preference and override any value set by bare bool use_tcp_for_dns_lookups value.
There was a problem hiding this comment.
I think you can use the presence of the dns_lookup_options message alone to detect that we aren't dealing with legacy configuration..
There was a problem hiding this comment.
Thanks for the suggestions. Not using BoolValue.
…of search namespaces when using the c-ares resolver and reconcile DNS options in a single message. Signed-off-by: Sunil Narasimhamurthy <sunnrs@amazon.com>
Signed-off-by: Sunil Narasimhamurthy <sunnrs@amazon.com>
Signed-off-by: Sunil Narasimhamurthy <sunnrs@amazon.com>
adisuissa
left a comment
There was a problem hiding this comment.
API looks good.
Left some drive-by comments on the non-api code.
include/envoy/event/dispatcher.h
Outdated
| * @param use_tcp_for_dns_lookups if set to true, tcp will be used to perform dns lookups. | ||
| * Otherwise, udp is used. |
There was a problem hiding this comment.
Removed. thanks for noticing
| "using TCP for DNS lookups is not possible when using Apple APIs for DNS " | ||
| "resolution. Apple' API only uses UDP for DNS resolution. Use UDP or disable " | ||
| "the envoy.restart_features.use_apple_api_for_dns_lookups runtime feature."); | ||
| return std::make_shared<Network::AppleDnsResolverImpl>(*this, api_.randomGenerator(), |
There was a problem hiding this comment.
Note that in this case the new no_default_search_domain flag won't be used to initialize the AppleDnsResolver.
There was a problem hiding this comment.
I need some clarity here. Originally AppleDnsResolver has problem using TCP for DNS resolution. Now as we introduce no_default_search_domain as DNS lookup/resolver options, nowhere in this PR we are making this options available for AppleDnsResolver.
Can you please suggest what we can do here?
- Should we find a way to pass this
no_default_search_domaininto the DNS resolver library thatAppleDnsResolveruses, or - Highlight that setting any options via
dns_resolver_optionsis not allowed forAppleDnsResolver? Before this PR there was already a RELEASE_ASSERT which make sure the user is not settinguse_tcp_for_dns_lookups. Should that be the norm for any options set viadns_resolver_optionsgoing forward ?
Please let me know. Thanks in advance.
| max_hosts_(PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, max_hosts, 1024)) { | ||
| envoy::config::core::v3::DnsResolverOptions dns_resolver_options; | ||
| if (config.has_dns_resolver_options()) { | ||
| const auto& config_dns_options = config.dns_resolver_options(); |
There was a problem hiding this comment.
Same as above.
Also not sure if the two pieces of code can be refactored, as they are essentially the same.
There was a problem hiding this comment.
Took care of this change. Need your thoughts here. In the updated changes the code looks like
envoy::config::core::v3::DnsResolverOptions dns_resolver_options;
if (cluster.has_dns_resolver_options()) {
dns_resolver_options.CopyFrom(cluster.dns_resolver_options());
} else {
// <code comment>
dns_resolver_options.set_use_tcp_for_dns_lookups(cluster.use_tcp_for_dns_lookups());
}
technically we don't need both the if & else condition. We could just do with
envoy::config::core::v3::DnsResolverOptions dns_resolver_options;
dns_resolver_options.CopyFrom(cluster.dns_resolver_options());
if (!cluster.has_dns_resolver_options()) {
dns_resolver_options.set_use_tcp_for_dns_lookups(cluster.use_tcp_for_dns_lookups());
}
But I thought it is better if we make it explicit that if legacy control plane has not configured dns_resolver_options then we stick to just setting dns_resolver_options.use_tcp... based on deprecated field use_tcp_for_dns_lookups.
source/server/server.cc
Outdated
| const bool use_tcp_for_dns_lookups = bootstrap_.use_tcp_for_dns_lookups(); | ||
| dns_resolver_ = dispatcher_->createDnsResolver({}, use_tcp_for_dns_lookups); | ||
| envoy::config::core::v3::DnsResolverOptions dns_resolver_options; | ||
| if (bootstrap_.has_dns_resolver_options()) { |
There was a problem hiding this comment.
Same as above.
I think this can be refactored to avoid code dup.
| const auto& cluster_dns_options = cluster.dns_resolver_options(); | ||
| dns_resolver_options.set_use_tcp_for_dns_lookups( | ||
| cluster_dns_options.use_tcp_for_dns_lookups()); | ||
| dns_resolver_options.set_no_default_search_domain( | ||
| cluster_dns_options.no_default_search_domain()); |
There was a problem hiding this comment.
Can you use something like CopyFrom here?
Otherwise, more fields will require manual copying.
…ssue in a Test Signed-off-by: Sunil Narasimhamurthy <sunnrs@amazon.com>
|
|
/retest |
|
Retrying Azure Pipelines: |
So restarting the tests. |
|
/retest |
|
Retrying Azure Pipelines: |
|
Hi @htuch & @adisuissa, this PR is ready for review. |
| // This may be overridden on a per-cluster basis in cds_config, when | ||
| // :ref:`dns_resolution_config <envoy_v3_api_field_config.cluster.v3.Cluster.dns_resolution_config>` | ||
| // is specified. | ||
| core.v3.DnsResolutionConfig dns_resolution_config = 30; |
There was a problem hiding this comment.
@yanjunxiang-google this is the proto message that DNS resolver extension should live in.
| bool use_tcp_for_dns_lookups = 1; | ||
|
|
||
| // Do not use the default search domains; only query hostnames as-is or as aliases. | ||
| bool no_default_search_domain = 2; |
There was a problem hiding this comment.
I think you should add a version history entry for this change.
Signed-off-by: Sunil Narasimhamurthy <sunnrs@amazon.com>
|
/lgtm api |
|
Hi Maintainers, this PR is ready for merge? |
|
cc @alyssawilk this is a case for the bot of a PR not getting a non-API reviewer. I will review. |
|
Ugh, this was definitely missed with old and new versions of the script, though I also see cases in maintainer-oncall where the API bug is definitely caught. Can't debug this easily since it's merged but please let me know if you see other cases :-( |
|
on no wait, this was caught, I just searched for the wrong string. So should be fixed forward as long as on-call goes through the list :-) |
|
Hi, I am running buf on some previous commits to the envoy api to see if there were any commits that break api compatibility and it detected this change as being non-backwards-compatible: Just wanted to flag it in case it was unintentional! cc @adisuissa |
|
@YaseenAlk what is the SHA or PR this happened at? I seem to remember OKing something like that because it was within a short window of the original commit, where we allow these changes, but I should verify. |
|
The incompatibility is between this PR and the PR at #16294 |
|
Yep, we allow breaking API changes within a 14 day window, see https://github.com/envoyproxy/envoy/blob/main/api/API_VERSIONING.md. Good catch though! |
|
@htuch The |
|
https://github.com/envoyproxy/envoy/blob/main/api/API_VERSIONING.md
@jpeach That is true, but the API is still v3alpha. Hope that is allowed. |
Is it possible to upgrade across the breaking change? i.e. I have to serve 1.18 and 1.19 clients concurrently. |
…ver (envoyproxy#16237) Signed-off-by: Sunil Narasimhamurthy <sunnrs@amazon.com>
Signed-off-by: Sunil Narasimhamurthy sunnrs@amazon.com
Commit Message: Modify API to support configuration of ARES flags to disable the use of search namespaces when using the c-ares resolver and reconcile DNS options in a single message
Additional Description:
Risk Level: low
Testing: unit test
Docs Changes: yes
Release Notes: updated new feature and deprecated list
Platform Specific Features:
Issues: #12432
Deprecated: field 'use_tcp_for_dns_lookups' in bootstrap, cluster & dynamic_forward_proxy xDS APIs