Skip to content

Commit 3739add

Browse files
authored
Set max attempts for Istio ServiceEntry DNS resolution and do not wait for first result (#13235)
1 parent 4f4323a commit 3739add

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

docs/en/changes/changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* BanyanDB: Support `@ShardingKey` for Measure tags and set to TopNAggregation group tag by default.
1616
* BanyanDB: Support cold stage data query for metrics/traces/logs.
1717
* Increase the idle check interval of the message queue to 200ms to reduce CPU usage under low load conditions.
18+
* 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.
1819

1920
#### UI
2021

oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/als/istio/IstioServiceEntryRegistry.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import com.google.common.cache.LoadingCache;
2424
import com.google.common.collect.ImmutableMap;
2525
import com.linecorp.armeria.client.endpoint.dns.DnsAddressEndpointGroup;
26+
import com.linecorp.armeria.client.retry.Backoff;
27+
2628
import io.fabric8.istio.api.networking.v1beta1.ServiceEntry;
2729
import io.fabric8.istio.api.networking.v1beta1.WorkloadEntrySpec;
2830
import io.fabric8.kubernetes.api.model.ObjectMeta;
@@ -100,16 +102,20 @@ public ServiceMetaInfo load(String ip) {
100102
return spec
101103
.getHosts()
102104
.parallelStream()
103-
.map(host -> hostnameResolvers.computeIfAbsent(host, it -> {
104-
final var endpointGroup = DnsAddressEndpointGroup.of(it);
105-
endpointGroup.whenReady().join(); // Wait for the first resolution
106-
return endpointGroup;
107-
}))
108-
.anyMatch(dnsAddressEndpointGroup ->
109-
dnsAddressEndpointGroup
110-
.endpoints()
111-
.parallelStream()
112-
.anyMatch(endpoint -> Objects.equals(endpoint.ipAddr(), ip)));
105+
.map(host -> hostnameResolvers.computeIfAbsent(host, it ->
106+
DnsAddressEndpointGroup.builder(it)
107+
.backoff(Backoff.exponential(1000, 32000).withJitter(0.2).withMaxAttempts(3))
108+
.build()
109+
))
110+
.anyMatch(dnsAddressEndpointGroup -> {
111+
if (dnsAddressEndpointGroup.whenReady().isDone()) {
112+
return dnsAddressEndpointGroup
113+
.endpoints()
114+
.parallelStream()
115+
.anyMatch(endpoint -> Objects.equals(endpoint.ipAddr(), ip));
116+
}
117+
return false;
118+
});
113119
default:
114120
log.debug("Unsupported service entry resolution: {}", spec.getResolution());
115121
return false;

0 commit comments

Comments
 (0)