Skip to content

fix: use ExecutorServiceManager to retrieve executor #1651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.fabric8.kubernetes.client.extended.leaderelection.LeaderElectorBuilder;
import io.fabric8.kubernetes.client.extended.leaderelection.resourcelock.LeaseLock;
import io.javaoperatorsdk.operator.api.config.ConfigurationServiceProvider;
import io.javaoperatorsdk.operator.api.config.ExecutorServiceManager;
import io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration;

public class LeaderElectionManager {
Expand Down Expand Up @@ -43,7 +44,7 @@ public void init(LeaderElectionConfiguration config, KubernetesClient client) {
// releaseOnCancel is not used in the underlying implementation
leaderElector =
new LeaderElectorBuilder(
client, ConfigurationServiceProvider.instance().getExecutorService())
client, ExecutorServiceManager.instance().executorService())
.withConfig(
new LeaderElectionConfig(
lock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import com.fasterxml.jackson.databind.ObjectMapper;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

class ConfigurationServiceOverriderTest {

Expand Down Expand Up @@ -86,6 +86,7 @@ public Optional<LeaderElectionConfiguration> getLeaderElectionConfiguration() {
.withClientConfiguration(new ConfigBuilder().withNamespace("newNS").build())
.checkingCRDAndValidateLocalModel(true)
.withExecutorService(Executors.newSingleThreadExecutor())
.withWorkflowExecutorService(Executors.newFixedThreadPool(4))
.withCloseClientOnStop(false)
.withObjectMapper(new ObjectMapper())
.withResourceCloner(new Cloner() {
Expand All @@ -111,6 +112,7 @@ public <R extends HasMetadata> R clone(R object) {
overridden.getTerminationTimeoutSeconds());
assertNotEquals(config.getClientConfiguration(), overridden.getClientConfiguration());
assertNotEquals(config.getExecutorService(), overridden.getExecutorService());
assertNotEquals(config.getWorkflowExecutorService(), overridden.getWorkflowExecutorService());
assertNotEquals(config.getMetrics(), overridden.getMetrics());
assertNotEquals(config.getObjectMapper(), overridden.getObjectMapper());
assertNotEquals(config.getLeaderElectionConfiguration(),
Expand Down