|
23 | 23 | import com.google.common.cache.LoadingCache; |
24 | 24 | import com.google.common.collect.ImmutableMap; |
25 | 25 | import com.linecorp.armeria.client.endpoint.dns.DnsAddressEndpointGroup; |
| 26 | +import com.linecorp.armeria.client.retry.Backoff; |
| 27 | + |
26 | 28 | import io.fabric8.istio.api.networking.v1beta1.ServiceEntry; |
27 | 29 | import io.fabric8.istio.api.networking.v1beta1.WorkloadEntrySpec; |
28 | 30 | import io.fabric8.kubernetes.api.model.ObjectMeta; |
@@ -100,16 +102,20 @@ public ServiceMetaInfo load(String ip) { |
100 | 102 | return spec |
101 | 103 | .getHosts() |
102 | 104 | .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 | + }); |
113 | 119 | default: |
114 | 120 | log.debug("Unsupported service entry resolution: {}", spec.getResolution()); |
115 | 121 | return false; |
|
0 commit comments