|
3 | 3 | import io.fabric8.kubernetes.api.model.*; |
4 | 4 | import io.fabric8.kubernetes.client.KubernetesClient; |
5 | 5 | import io.fabric8.kubernetes.client.KubernetesClientBuilder; |
| 6 | +import io.fabric8.kubernetes.client.KubernetesClientException; |
6 | 7 | import io.fabric8.kubernetes.client.dsl.base.ResourceDefinitionContext; |
7 | 8 | import java.net.InetAddress; |
8 | 9 | import java.net.UnknownHostException; |
@@ -186,25 +187,29 @@ private List<Pod> fetchDataNodes() { |
186 | 187 | // ============================================================================ |
187 | 188 |
|
188 | 189 | private String getListenerVersion() { |
189 | | - var crd = client.apiextensions().v1().customResourceDefinitions().withName("listeners").get(); |
190 | | - |
191 | | - if (crd != null && !crd.getSpec().getVersions().isEmpty()) { |
192 | | - // Select the version that is served and used for storage (the "stable" version) |
193 | | - for (var version : crd.getSpec().getVersions()) { |
194 | | - if (version.getServed() && version.getStorage()) { |
195 | | - return version.getName(); // Prefer the stable version |
| 190 | + try { |
| 191 | + var crd = client.apiextensions().v1().customResourceDefinitions().withName("listeners").get(); |
| 192 | + |
| 193 | + if (crd != null && !crd.getSpec().getVersions().isEmpty()) { |
| 194 | + // Select the version that is served and used for storage (the "stable" version) |
| 195 | + for (var version : crd.getSpec().getVersions()) { |
| 196 | + if (version.getServed() && version.getStorage()) { |
| 197 | + return version.getName(); // Prefer the stable version |
| 198 | + } |
196 | 199 | } |
197 | | - } |
198 | 200 |
|
199 | | - // If no stable version found, return the first served version as a fallback |
200 | | - for (var version : crd.getSpec().getVersions()) { |
201 | | - if (version.getServed()) { |
202 | | - return version.getName(); // Just pick the first served version if no stable one |
| 201 | + // If no stable version found, return the first served version as a fallback |
| 202 | + for (var version : crd.getSpec().getVersions()) { |
| 203 | + if (version.getServed()) { |
| 204 | + return version.getName(); // Just pick the first served version if no stable one |
| 205 | + } |
203 | 206 | } |
204 | 207 | } |
| 208 | + throw new RuntimeException("Unable to fetch CRD version for listeners"); |
| 209 | + } catch (KubernetesClientException e) { |
| 210 | + LOG.error("Unable to fetch CRD version for listeners. Failed with {}", e); |
| 211 | + throw new RuntimeException("Unable to fetch CRD version for listeners"); |
205 | 212 | } |
206 | | - LOG.error("Unable to fetch CRD version for listeners"); |
207 | | - throw new RuntimeException("Unable to fetch CRD version for listeners"); |
208 | 213 | } |
209 | 214 |
|
210 | 215 | private List<String> resolveListeners(List<String> names) { |
|
0 commit comments