Skip to content

fix: pool size configuration #2810

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
May 20, 2025
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 @@ -254,13 +254,20 @@ public boolean closeClientOnStop() {

@Override
public ExecutorService getExecutorService() {
return overriddenValueOrDefault(executorService, ConfigurationService::getExecutorService);
if (executorService != null) {
return executorService;
} else {
return super.getExecutorService();
}
}

@Override
public ExecutorService getWorkflowExecutorService() {
return overriddenValueOrDefault(
workflowExecutorService, ConfigurationService::getWorkflowExecutorService);
if (workflowExecutorService != null) {
return workflowExecutorService;
} else {
return super.getWorkflowExecutorService();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import java.time.Duration;
import java.util.Optional;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

import org.junit.jupiter.api.Test;

import io.fabric8.kubernetes.api.model.HasMetadata;
import io.javaoperatorsdk.operator.api.monitoring.Metrics;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

class ConfigurationServiceOverriderTest {
Expand All @@ -26,30 +28,32 @@ public <R extends HasMetadata> R clone(R object) {
}
};

final BaseConfigurationService config =
new BaseConfigurationService(null) {
@Override
public boolean checkCRDAndValidateLocalModel() {
return false;
}

@Override
public Metrics getMetrics() {
return METRICS;
}

@Override
public Cloner getResourceCloner() {
return CLONER;
}

@Override
public Optional<LeaderElectionConfiguration> getLeaderElectionConfiguration() {
return Optional.of(LEADER_ELECTION_CONFIGURATION);
}
};

@Test
void overrideShouldWork() {
final var config =
new BaseConfigurationService(null) {
@Override
public boolean checkCRDAndValidateLocalModel() {
return false;
}

@Override
public Metrics getMetrics() {
return METRICS;
}

@Override
public Cloner getResourceCloner() {
return CLONER;
}

@Override
public Optional<LeaderElectionConfiguration> getLeaderElectionConfiguration() {
return Optional.of(LEADER_ELECTION_CONFIGURATION);
}
};

final var overridden =
new ConfigurationServiceOverrider(config)
.checkingCRDAndValidateLocalModel(true)
Expand Down Expand Up @@ -86,4 +90,17 @@ public <R extends HasMetadata> R clone(R object) {
assertNotEquals(
config.reconciliationTerminationTimeout(), overridden.reconciliationTerminationTimeout());
}

@Test
void threadCountConfiguredProperly() {
final var overridden =
new ConfigurationServiceOverrider(config)
.withConcurrentReconciliationThreads(13)
.withConcurrentWorkflowExecutorThreads(14)
.build();
assertThat(((ThreadPoolExecutor) overridden.getExecutorService()).getMaximumPoolSize())
.isEqualTo(13);
assertThat(((ThreadPoolExecutor) overridden.getWorkflowExecutorService()).getMaximumPoolSize())
.isEqualTo(14);
}
}