Repository navigation
Description
the DNS filter uses the standard dns resolver that the dispatcher creates. The Dispatcher creates the c-ares resolver with default options. In the case of the DNS filter whose job is to receive and resolve DNS queries from the app (on a VM or k8s pod), the following happens:
- app container has resolv.conf with 4 search domains ( ns1.svc.cluster.local svc.cluster.local cluster.local google.internal)
- envoy sidecar container also has the same resolv.conf that c-ares uses
When the application container has to resolve a DNS name such as svc1.ns2, (where ndots: 5), glibc (or whatever is responsible) will use resolv.conf to expand it to the following search queries
svc1.ns2.ns1.svc.cluster.local
svc1.ns2.svc.cluster.local
svc1.ns2.cluster.local
svc1.ns2.google.internal
When the first query hits envoy, its DNS filter will most probably not have the invalid hostname svc1.ns2.ns1.svc.cluster.local. The DNs filter will then use the system's resolvers (or user provided upstream resolvers). But here is the catch. The search for various DNS search namespaces happens again.. i.e. c-ares resolver will attempt to resolve all the following
svc1.ns2.ns1.svc.cluster.local
svc1.ns2.ns1.svc.cluster.local.ns1.svc.cluster.local
svc1.ns2.ns1.svc.cluster.local.svc.cluster.local
svc1.ns2.ns1.svc.cluster.local.cluster.local
svc1.ns2.ns1.svc.cluster.local.google.internal
This literally ends up in a lot of useless queries, and much longer time to resolve DNS queries than what should usually take. The same problem happens on VMs as well. The only time this is not a problem is when someone is running Envoy as a standalone DNS server somewhere on the network, but for the other use cases, this clearly results in suboptimal behavior.
The solution is to disable the use of search namespaces when using the c-ares resolver in the DNS filter. Specifically, the dispatcher needs to have an option for this (just like use_tcp_for_dns), that then translates to c-ares' ARES_FLAG_NOSEARCH opt flag (https://c-ares.haxx.se/ares_init_options.html).
Activity
dio commentedon Aug 3, 2020
It seems like this is not directly related to the DNS filter (sorry for tagging you too early, @abaptiste). And I would like to highlight: #8588 (comment) and #8084 (comment). If someone wants to work on this, seems like we need to rectify "Reconcile DNS options in a single message" e.g. to have
DnsLookupOptionsinapi/envoy/config/core/v3/base.proto(not sure about the location). That means to "push" it earlier than the "next-major-version". WDYT @lizan @mattklein123 @envoyproxy/api-shepherds? If that is OK, I can try to tackle this. Thanks!lizan commentedon Aug 3, 2020
As long as we follow normal deprecation / non-breaking policy, that sounds reasonable.
mattklein123 commentedon Aug 3, 2020
Yup +1
suniltheta commentedon Apr 19, 2021
Hi, I would like to take a stab at this issue. Can someone please assign it to me? Thanks.
Tagging for attention @mattklein123, @dio, @lizan or @asraa
suniltheta commentedon Jun 2, 2021
Can we close this issue, now that PR #16237 is merged? Thanks.