Skip to content

Commit 0a53a65

Browse files
committed
more logging
1 parent 812033e commit 0a53a65

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/main/java/tech/stackable/hadoop/StackableTopologyProvider.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class StackableTopologyProvider implements DNSToSwitchMapping {
2929
// Default values
3030
public static final String DEFAULT_RACK = "/defaultRack";
3131
private static final int CACHE_EXPIRY_DEFAULT_SECONDS = 5 * 60;
32+
// Cache on first usage (not on start-up to avoid attempts before listeners are available)
3233
private String listenerVersion;
3334

3435
private final KubernetesClient client;
@@ -200,21 +201,22 @@ private String getListenerVersion() {
200201
// Select the version that is served and used for storage (the "stable" version)
201202
for (var version : crd.getSpec().getVersions()) {
202203
if (version.getServed() && version.getStorage()) {
203-
return version.getName(); // Prefer the stable version
204+
LOG.debug("Returning served/stored version: {}", version.getName());
205+
return version.getName();
204206
}
205207
}
206-
207208
// If no stable version found, return the first served version as a fallback
208209
for (var version : crd.getSpec().getVersions()) {
209210
if (version.getServed()) {
210-
return version.getName(); // Just pick the first served version if no stable one
211+
LOG.debug("Returning served/un-stored version: {}", version.getName());
212+
return version.getName();
211213
}
212214
}
213215
}
214216
LOG.error("Unable to fetch CRD version for listeners. Returning default value.");
215217
return "v1alpha1";
216218
} catch (KubernetesClientException e) {
217-
LOG.error("Unable to fetch CRD version for listeners. Failed with {}", e);
219+
LOG.error("Unable to fetch CRD version for listeners. Throwing exception.", e);
218220
throw new RuntimeException("Unable to fetch CRD version for listeners");
219221
}
220222
}
@@ -233,9 +235,7 @@ private void refreshListenerCacheIfNeeded(List<String> names) {
233235
LOG.debug("Listener cache contains all required entries");
234236
return;
235237
}
236-
237238
// Listeners are typically few, so fetch all
238-
// (Individual listener fetches would require knowing the namespace)
239239
LOG.debug("Fetching all listeners to populate cache");
240240
if (listenerVersion == null) {
241241
listenerVersion = getListenerVersion();
@@ -250,10 +250,12 @@ private void refreshListenerCacheIfNeeded(List<String> names) {
250250

251251
private void cacheListenerByNameAndAddresses(GenericKubernetesResource listener) {
252252
String name = listener.getMetadata().getName();
253+
LOG.debug("Caching listener by name: {}", name);
253254
cache.putListener(name, listener);
254255

255256
// Also cache by ingress addresses for quick lookup
256257
for (String address : TopologyUtils.getIngressAddresses(listener)) {
258+
LOG.debug("Caching listener by address: {}", address);
257259
cache.putListener(address, listener);
258260
}
259261
}

0 commit comments

Comments
 (0)