From cbb7b6e3fbd0e599349c1031e3dce281e8e4ad95 Mon Sep 17 00:00:00 2001 From: "update-envoy[bot]" <135279899+update-envoy[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 14:01:46 +0000 Subject: [PATCH] =?UTF-8?q?dns=20resolver:=20add=20options=20to=20initiali?= =?UTF-8?q?ze=20c-ares=20with=20custom=20timeout=20an=E2=80=A6=20(#36947)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Background We recently saw a small number of DNS queries getting timed out. There is currently no option for us to [initialize c-ares](https://c-ares.org/ares_init_options.html) by passing in a custom [timeout](https://c-ares.org/ares_init_options.html#:~:text=c%2Dares%201.5.2.-,ARES_OPT_TIMEOUTMS,-int%20timeout%3B) and [tries](https://c-ares.org/ares_init_options.html#:~:text=c%2Dares%201.5.2.-,ARES_OPT_TRIES,-int%20tries%3B) config options. ## Changes In this PR, we are adding two new options in c-ares resolver for configuring custom timeouts and tries while resolving DNS queries. Custom timeouts could be configured by specifying `query_timeout_seconds` option and custom tries could be configured by specifying `query_tries` config option. **Commit Message:** dns resolver: add options to initialize c-ares with custom timeout and tries **Additional Description:** add two new options called `query_timeout_seconds` and `query_tries` for initializing c-ares with custom timeout and tries. **Risk Level:** Low **Testing:** Added Unit/Integration Tests **Docs Changes:** Added **Release Notes:** Added **Platform Specific Features:** N/A --------- Signed-off-by: Rohit Agrawal Mirrored from https://github.com/envoyproxy/envoy @ 0a2e904c7f1b8232e5e9700f2d995a76f4c84014 --- .../cares/v3/cares_dns_resolver.proto | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/envoy/extensions/network/dns_resolver/cares/v3/cares_dns_resolver.proto b/envoy/extensions/network/dns_resolver/cares/v3/cares_dns_resolver.proto index c3a8d35a..5d646c25 100644 --- a/envoy/extensions/network/dns_resolver/cares/v3/cares_dns_resolver.proto +++ b/envoy/extensions/network/dns_resolver/cares/v3/cares_dns_resolver.proto @@ -8,6 +8,7 @@ import "envoy/config/core/v3/resolver.proto"; import "google/protobuf/wrappers.proto"; import "udpa/annotations/status.proto"; +import "validate/validate.proto"; option java_package = "io.envoyproxy.envoy.extensions.network.dns_resolver.cares.v3"; option java_outer_classname = "CaresDnsResolverProto"; @@ -19,7 +20,7 @@ option (udpa.annotations.file_status).package_version_status = ACTIVE; // [#extension: envoy.network.dns_resolver.cares] // Configuration for c-ares DNS resolver. -// [#next-free-field: 6] +// [#next-free-field: 8] message CaresDnsResolverConfig { // A list of dns resolver addresses. // :ref:`use_resolvers_as_fallback` @@ -47,4 +48,17 @@ message CaresDnsResolverConfig { // This option allows for number of UDP based DNS queries to be capped. Note, this // is only applicable to c-ares DNS resolver currently. google.protobuf.UInt32Value udp_max_queries = 5; + + // The number of seconds each name server is given to respond to a query on the first try of any given server. + // + // Note: While the c-ares library defaults to 2 seconds, Envoy's default (if this field is unset) is 5 seconds. + // This adjustment was made to maintain the previous behavior after users reported an increase in DNS resolution times. + google.protobuf.UInt64Value query_timeout_seconds = 6 [(validate.rules).uint64 = {gte: 1}]; + + // The maximum number of query attempts the resolver will make before giving up. + // Each attempt may use a different name server. + // + // Note: While the c-ares library defaults to 3 attempts, Envoy's default (if this field is unset) is 4 attempts. + // This adjustment was made to maintain the previous behavior after users reported an increase in DNS resolution times. + google.protobuf.UInt32Value query_tries = 7 [(validate.rules).uint32 = {gte: 1}]; }