Skip to content

Commit 1fecdf9

Browse files
authored
fix: properly report missing CRDs from informers (#1541)
Fixes #1539
1 parent a9082e2 commit 1fecdf9

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/ReconcilerUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public static void handleKubernetesClientException(Exception e, String resourceT
133133
// only throw MissingCRDException if the 404 error occurs on the target CRD
134134
if (resourceTypeName.equals(ke.getFullResourceName())
135135
|| matchesResourceType(resourceTypeName, ke)) {
136-
throw new MissingCRDException(resourceTypeName, null, e.getMessage(), e);
136+
throw new MissingCRDException(resourceTypeName, ke.getVersion(), e.getMessage(), e);
137137
}
138138
}
139139
}

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/Controller.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public synchronized void start(boolean startEventProcessor) throws OperatorExcep
299299
log.info("'{}' controller started, pending event sources initialization", controllerName);
300300
} catch (MissingCRDException e) {
301301
stop();
302-
throwMissingCRDException(crdName, specVersion, controllerName);
302+
throwMissingCRDException(e.getCrdName(), e.getSpecVersion(), controllerName);
303303
}
304304
}
305305

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/InformerWrapper.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import java.util.function.Predicate;
88
import java.util.stream.Stream;
99

10+
import org.slf4j.Logger;
11+
import org.slf4j.LoggerFactory;
12+
1013
import io.fabric8.kubernetes.api.model.HasMetadata;
1114
import io.fabric8.kubernetes.client.informers.ResourceEventHandler;
1215
import io.fabric8.kubernetes.client.informers.SharedIndexInformer;
@@ -20,6 +23,8 @@
2023
class InformerWrapper<T extends HasMetadata>
2124
implements LifecycleAware, IndexerResourceCache<T> {
2225

26+
private static final Logger log = LoggerFactory.getLogger(InformerWrapper.class);
27+
2328
private final SharedIndexInformer<T> informer;
2429
private final Cache<T> cache;
2530

@@ -33,8 +38,12 @@ public void start() throws OperatorException {
3338
try {
3439
informer.run();
3540
} catch (Exception e) {
36-
ReconcilerUtils.handleKubernetesClientException(e,
37-
HasMetadata.getFullResourceName(informer.getApiTypeClass()));
41+
final var apiTypeClass = informer.getApiTypeClass();
42+
final var fullResourceName = HasMetadata.getFullResourceName(apiTypeClass);
43+
final var version = HasMetadata.getVersion(apiTypeClass);
44+
log.error("Couldn't start informer for " + fullResourceName + "/" + version + " resources",
45+
e);
46+
ReconcilerUtils.handleKubernetesClientException(e, fullResourceName);
3847
throw e;
3948
}
4049
}

0 commit comments

Comments
 (0)