Set max attempts for Istio ServiceEntry DNS resolution and do not wait for first result (#13235)

This commit is contained in:
kezhenxu94 2025-05-09 12:53:42 +08:00 committed by GitHub
parent 4f4323a42b
commit 3739add599
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 10 deletions

View File

@ -15,6 +15,7 @@
* BanyanDB: Support `@ShardingKey` for Measure tags and set to TopNAggregation group tag by default.
* BanyanDB: Support cold stage data query for metrics/traces/logs.
* Increase the idle check interval of the message queue to 200ms to reduce CPU usage under low load conditions.
* Limit max attempts of DNS resolution of Istio ServiceEntry to 3, and do not wait for first resolution result in case the DNS is not resolvable at all.
#### UI

View File

@ -23,6 +23,8 @@ import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMap;
import com.linecorp.armeria.client.endpoint.dns.DnsAddressEndpointGroup;
import com.linecorp.armeria.client.retry.Backoff;
import io.fabric8.istio.api.networking.v1beta1.ServiceEntry;
import io.fabric8.istio.api.networking.v1beta1.WorkloadEntrySpec;
import io.fabric8.kubernetes.api.model.ObjectMeta;
@ -100,16 +102,20 @@ public class IstioServiceEntryRegistry {
return spec
.getHosts()
.parallelStream()
.map(host -> hostnameResolvers.computeIfAbsent(host, it -> {
final var endpointGroup = DnsAddressEndpointGroup.of(it);
endpointGroup.whenReady().join(); // Wait for the first resolution
return endpointGroup;
}))
.anyMatch(dnsAddressEndpointGroup ->
dnsAddressEndpointGroup
.endpoints()
.parallelStream()
.anyMatch(endpoint -> Objects.equals(endpoint.ipAddr(), ip)));
.map(host -> hostnameResolvers.computeIfAbsent(host, it ->
DnsAddressEndpointGroup.builder(it)
.backoff(Backoff.exponential(1000, 32000).withJitter(0.2).withMaxAttempts(3))
.build()
))
.anyMatch(dnsAddressEndpointGroup -> {
if (dnsAddressEndpointGroup.whenReady().isDone()) {
return dnsAddressEndpointGroup
.endpoints()
.parallelStream()
.anyMatch(endpoint -> Objects.equals(endpoint.ipAddr(), ip));
}
return false;
});
default:
log.debug("Unsupported service entry resolution: {}", spec.getResolution());
return false;