From 1950eb4913efcfbf01e7df8f8b1534bec3e60866 Mon Sep 17 00:00:00 2001 From: csviri Date: Fri, 29 Oct 2021 10:51:25 +0200 Subject: [PATCH 1/2] feature!: throw exception if controller cannot be registered If a controller cannot be registered because of cofirguration loading is a programatic error, should be reported asap. Logging just a warning would make it hard to find out where is the problem and why the controller not starting --- .../java/io/javaoperatorsdk/operator/Operator.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java index ae094b25c6..a9dc7638a9 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java @@ -137,12 +137,11 @@ public void close() { throws OperatorException { final var existing = configurationService.getConfigurationFor(controller); if (existing == null) { - log.warn( - "Skipping registration of {} controller named {} because its configuration cannot be found.\n" - + "Known controllers are: {}", - controller.getClass().getCanonicalName(), - ControllerUtils.getNameFor(controller), - configurationService.getKnownControllerNames()); + throw new IllegalStateException( + "Cannot register controller with name " + controller.getClass().getCanonicalName() + + " controller named " + ControllerUtils.getNameFor(controller) + + " because its configuration cannot be found.\n" + + " Known controllers are: " + configurationService.getKnownControllerNames()); } else { if (configuration == null) { configuration = existing; From bc40b987be34e8f98bc6da4a03497f607a269b32 Mon Sep 17 00:00:00 2001 From: csviri Date: Fri, 29 Oct 2021 11:03:10 +0200 Subject: [PATCH 2/2] fix: operator exception thrown --- .../src/main/java/io/javaoperatorsdk/operator/Operator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java index a9dc7638a9..8812d8d6b3 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java @@ -137,7 +137,7 @@ public void close() { throws OperatorException { final var existing = configurationService.getConfigurationFor(controller); if (existing == null) { - throw new IllegalStateException( + throw new OperatorException( "Cannot register controller with name " + controller.getClass().getCanonicalName() + " controller named " + ControllerUtils.getNameFor(controller) + " because its configuration cannot be found.\n" +