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 8ece5334fd..39298c2ee0 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 @@ -105,8 +105,8 @@ public void stop() throws OperatorException { */ public void register(Reconciler reconciler) throws OperatorException { - final var defaultConfiguration = configurationService.getConfigurationFor(reconciler); - register(reconciler, defaultConfiguration); + final var controllerConfiguration = configurationService.getConfigurationFor(reconciler); + register(reconciler, controllerConfiguration); } /** diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverrider.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverrider.java index b96f510d97..c9b60d2617 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverrider.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverrider.java @@ -70,7 +70,10 @@ public ConfigurationService build() { @Override public ControllerConfiguration getConfigurationFor( Reconciler reconciler) { - return original.getConfigurationFor(reconciler); + ControllerConfiguration controllerConfiguration = + original.getConfigurationFor(reconciler); + controllerConfiguration.setConfigurationService(this); + return controllerConfiguration; } @Override diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/EventProcessor.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/EventProcessor.java index 3b9ecb2c82..33c2b7645b 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/EventProcessor.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/EventProcessor.java @@ -66,21 +66,6 @@ class EventProcessor implements EventHandler, LifecycleAw eventSourceManager); } - EventProcessor( - ReconciliationDispatcher reconciliationDispatcher, - EventSourceManager eventSourceManager, - String relatedControllerName, - Retry retry) { - this( - eventSourceManager.getControllerResourceEventSource().getResourceCache(), - null, - relatedControllerName, - reconciliationDispatcher, - retry, - null, - eventSourceManager); - } - EventProcessor( ReconciliationDispatcher reconciliationDispatcher, EventSourceManager eventSourceManager, diff --git a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/EventProcessorTest.java b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/EventProcessorTest.java index b462182921..5a3f73742e 100644 --- a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/EventProcessorTest.java +++ b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/EventProcessorTest.java @@ -61,11 +61,12 @@ public void setup() { when(controllerResourceEventSourceMock.getResourceCache()).thenReturn(resourceCacheMock); eventProcessor = - spy(new EventProcessor(reconciliationDispatcherMock, eventSourceManagerMock, "Test", null)); + spy(new EventProcessor(reconciliationDispatcherMock, eventSourceManagerMock, "Test", null, + null)); eventProcessor.start(); eventProcessorWithRetry = spy(new EventProcessor(reconciliationDispatcherMock, eventSourceManagerMock, "Test", - GenericRetry.defaultLimitedExponentialRetry())); + GenericRetry.defaultLimitedExponentialRetry(), null)); eventProcessorWithRetry.start(); when(eventProcessor.retryEventSource()).thenReturn(retryTimerEventSourceMock); diff --git a/sample-operators/mysql-schema/pom.xml b/sample-operators/mysql-schema/pom.xml index 6f021b383f..f1a3c3ddc1 100644 --- a/sample-operators/mysql-schema/pom.xml +++ b/sample-operators/mysql-schema/pom.xml @@ -27,6 +27,11 @@ operator-framework ${project.version} + + io.javaoperatorsdk + micrometer-support + ${project.version} + org.takes takes diff --git a/sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/MySQLSchemaOperator.java b/sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/MySQLSchemaOperator.java index fbb9ae2b65..ebccbd4fe5 100644 --- a/sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/MySQLSchemaOperator.java +++ b/sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/MySQLSchemaOperator.java @@ -14,7 +14,10 @@ import io.fabric8.kubernetes.client.DefaultKubernetesClient; import io.fabric8.kubernetes.client.KubernetesClient; import io.javaoperatorsdk.operator.Operator; +import io.javaoperatorsdk.operator.api.config.ConfigurationServiceOverrider; import io.javaoperatorsdk.operator.config.runtime.DefaultConfigurationService; +import io.javaoperatorsdk.operator.monitoring.micrometer.MicrometerMetrics; +import io.micrometer.core.instrument.logging.LoggingMeterRegistry; public class MySQLSchemaOperator { @@ -25,7 +28,10 @@ public static void main(String[] args) throws IOException { Config config = new ConfigBuilder().withNamespace(null).build(); KubernetesClient client = new DefaultKubernetesClient(config); - Operator operator = new Operator(client, DefaultConfigurationService.instance()); + Operator operator = new Operator(client, + new ConfigurationServiceOverrider(DefaultConfigurationService.instance()) + .withMetrics(new MicrometerMetrics(new LoggingMeterRegistry())) + .build()); operator.register(new MySQLSchemaReconciler(client, MySQLDbConfig.loadFromEnvironmentVars())); operator.installShutdownHook(); operator.start();