Skip to content

Commit

Permalink
fix: override executor replaces implementation event if not needed (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
csviri authored Apr 27, 2023
1 parent e63b720 commit 2c51ca7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Consumer;

import io.fabric8.kubernetes.client.Config;
Expand Down Expand Up @@ -191,13 +190,13 @@ public boolean closeClientOnStop() {
@Override
public ExecutorService getExecutorService() {
return executorService != null ? executorService
: Executors.newFixedThreadPool(concurrentReconciliationThreads());
: super.getExecutorService();
}

@Override
public ExecutorService getWorkflowExecutorService() {
return workflowExecutorService != null ? workflowExecutorService
: Executors.newFixedThreadPool(concurrentWorkflowExecutorThreads());
: super.getWorkflowExecutorService();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,5 @@ public <R extends HasMetadata> R clone(R object) {
assertNotEquals(config.getInformerStoppedHandler(),
overridden.getLeaderElectionConfiguration());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
import org.slf4j.LoggerFactory;

import io.fabric8.kubernetes.api.model.HasMetadata;
import io.javaoperatorsdk.operator.api.config.ConfigurationServiceProvider;
import io.javaoperatorsdk.operator.api.config.ControllerConfiguration;
import io.javaoperatorsdk.operator.api.config.ExecutorServiceManager;
import io.javaoperatorsdk.operator.api.config.RetryConfiguration;
import io.javaoperatorsdk.operator.api.config.*;
import io.javaoperatorsdk.operator.api.monitoring.Metrics;
import io.javaoperatorsdk.operator.processing.event.rate.LinearRateLimiter;
import io.javaoperatorsdk.operator.processing.event.rate.RateLimiter;
Expand Down Expand Up @@ -430,7 +427,10 @@ void executionOfReconciliationShouldNotStartIfProcessorStopped() throws Interrup
return PostExecutionControl.defaultDispatch();
});
// one event will lock the thread / executor
ConfigurationServiceProvider.overrideCurrent(o -> o.withConcurrentReconciliationThreads(1));
ConfigurationServiceProvider.overrideCurrent(o -> {
o.withConcurrentReconciliationThreads(1);
o.withMinConcurrentReconciliationThreads(1);
});
ExecutorServiceManager.reset();
eventProcessor.start();

Expand Down Expand Up @@ -490,6 +490,7 @@ ControllerConfiguration controllerConfiguration(Retry retry, RateLimiter rateLim
when(res.getRetry()).thenReturn(retry);
when(res.getRateLimiter()).thenReturn(rateLimiter);
when(res.maxReconciliationInterval()).thenReturn(Optional.of(Duration.ofMillis(1000)));
when(res.getConfigurationService()).thenReturn(new BaseConfigurationService());
return res;
}

Expand Down

0 comments on commit 2c51ca7

Please sign in to comment.