-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a way to customize via Spring framework a TTL for Netty's DNS cache #3517
Comments
@spring-cloud-issues any update on this issue? i was also facing same problem mentioned in this issue and was looking for help. |
@dimzul did you find any workarounds for this problem? I am happy to connect with you to discuss further. |
@bindupatnaik, unfortunately, no: all provided solutions don't have any effect on DNS cache TTL in Netty. I've debugged it locally and tested in real cluster and got the same result with default TTL applied. Also no effect with switching to JVM built-in resolver via: @Override
public HttpClient customize(HttpClient httpClient) {
httpClient
.resolver(DefaultAddressResolverGroup.INSTANCE)
.tcpConfiguration(tcpClient -> tcpClient.resolver(DefaultAddressResolverGroup.INSTANCE));
return httpClient;
} If you find a solution, please share it here. |
This configuration is not quite correct. You either use the
I also do not recommend using |
Note that the fluent config methods in reactor-netty's @Override
public HttpClient customize(HttpClient httpClient) {
return httpClient
.resolver(DefaultAddressResolverGroup.INSTANCE)
.tcpConfiguration(tcpClient -> tcpClient.resolver(DefaultAddressResolverGroup.INSTANCE));
} |
Problem
In k8s environment multiple instances of the same service are hidden by k8s Service name (like,
my-test.my-namespace.svc.cluster.local
). Same goes with DNS servers in k8s: multiple instances of it are hidden by k8s Service. In a case when one DNS server instance dies and emerges on a new k8s node with another IP address, due to DNS cache in Netty (transitive dependency of project-reactor) via DnsNameResolverBuilder and DefaultAuthoritativeDnsServerCache, IP addresses of DNS servers are cached forInteger.MAX_VALUE
seconds by default and old/cached IP address is used for DNS resolution. This results in a request to the IP address with no listening DNS server and causes next error:Steps to reproduce
Following suggestions by @violetagg and @spencergibb on customizing DNS cache TTL and TcpClient in Spring Cloud Gateway, a next configuration was made:
Having such a configuration, multiple instances of
DnsNameResolverBuilder
were created: 2 with the configured cache TTL and 2 with the default cache TTL:But when an actual request comes in, the
DnsNameResolverBuilder
with a default cache TTL configuration is used and DNS cache with default TTL (2147483647 seconds) is applied:Expected result
There is a way to configure DNS cache TTL via Spring Framework.
Versions
spring boot/spring-cloud-starter-gateway/spring-boot-starter-webflux: 3.2.8
reactor-netty-http: 1.1.21
netty: 4.1.111.Final
The text was updated successfully, but these errors were encountered: