netty/netty

DNSResolve: DNS Cache Not Working in Certain Scenarios

Closed this issue · 3 comments

qnnn commented
  1. In k8s environment, the concatenation of the hostname and searchDomain, can cause the DNS cache to become ineffective. I think if searchDomains are concatenated during DNS resolution, we should iterate through and concatenate all searchDomains to obtain the cached results.

    eg.
    hostname: k8s service name
    image-20240510234145365

  2. Each EpollEventLoop has its own DNS resolution cache, but when DNS resolution is executed in an EpollEventLoop that does not have a cached result, it can cause the DNS resolution cache to become ineffective.

This looks like a potential bug. Can it be assigned to me? I would like to try fixing it.

Netty version

4.1.73.Final

JVM version (e.g. java -version)

jdk8

OS version (e.g. uname -a)

k8s 5.15.0-101-generic #111-Ubuntu SMP Tue Mar 5 20:16:58 UTC 2024 x86_64 GNU/Linux

You are welcome to try fixing it. I recommend first making sure it's still a bug in the latest version. Then see if you can capture it in an automated test. Also feel free to discuss the ideas you have for how to fix it.

qnnn commented

You are welcome to try fixing it. I recommend first making sure it's still a bug in the latest version. Then see if you can capture it in an automated test. Also feel free to discuss the ideas you have for how to fix it.

This bug still exists in the latest version. If each type of DNSCache implementation has its own global cache, it should be able to resolve the issue mentioned above, and the cost of fixing it would be relatively low. In the ResolveWithDotSearchDomain scenario, I have made some small modifications by iterating through all searchDomains and matching 'hostname+ '.' +searchDomain' to search for results in the DNSCache. Would this be an appropriate solution?
please review: 4.1...qnnn:netty:4.1

Best wishes!

qnnn commented

@chrisvest Or, we could initialize the DNSCache by default in the DnsAddressResolverGroup during initialization. If the DnsNameResolverBuilder does not already have a DNSCache, we can use the same DNSCache when creating the NameResolver. WDYT?