Closed orange-guo closed 4 months ago
This looks reasonable to me.
When this case occurs, and you have no DNS servers (i.e. /etc/resolv.conf
is empty), what happens in your app with regards to DNS? Do requests fails (I'm guessing)? Or is your app just not using DNS?
I'm mostly curious because this helper will set the following two config settings, which disable DNS caching in the JVM, and I'm wondering if it might still be a good idea to do this if that file is empty. Even if you have no DNS servers, if your app tried to resolve a DNS that would presumably fail and the JVM might cache that result (not 100% sure it caches failures, or just successes, I didn't look). Probably not a big deal either way, but thought I'd ask.
networkaddress.cache.ttl=0
networkaddress.cache.negative.ttl=0
Thanks!
The application is deployed into the on-prem environment in my case, so the application does not use DNS.
In Linux, /etc/nsswitch.conf
is used to configure how the system finds a host,
for example:
hosts: dns nis files
If the host is not found from the aforementioned sources, Java may throw an error similar to "Temporary failure in name resolution."
networkaddress.cache.ttl
networkaddress.cache.negative.ttl
These parameters are looks like the host caching parameters
In cases no DNS, the decision to disable caching may depend on the frequency of content changes in other host sources, such as (files, nis) in /etc/nsswitch.conf
.
However, it is generally difficult to make assumptions about the frequency of these changes.
Therefore, I think that explicitly configuring to disable the cache might be a better approach.
This approach is ensure that the system does not rely on potentially outdated or incorrect information from other host sources.
Summary
Use
return
to instead ofruntime panic
if there no nameservers are found in /etc/resolve.confIn the following case, the nameservers are empty
The container uses the host network but the nameserver is empty in the host file
Use Cases
If nameservers are empty, no runtime panic
Checklist