Skip to content

Commit ac9b75e

Browse files
committed
feat: expose more configuration options
1 parent ec23c33 commit ac9b75e

File tree

6 files changed

+81
-13
lines changed

6 files changed

+81
-13
lines changed

core/runtime/src/main/java/io/quarkiverse/operatorsdk/runtime/BuildTimeOperatorConfiguration.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,36 @@ public class BuildTimeOperatorConfiguration {
2424

2525
/**
2626
* Whether controllers should only process events if the associated resource generation has
27-
* increased since last reconciliation, otherwise will process all events. Sets the default value for all controllers.
27+
* increased since last reconciliation, otherwise will process all events. Sets the default value
28+
* for all controllers.
2829
*/
2930
@ConfigItem(defaultValue = "true")
3031
public Optional<Boolean> generationAware;
3132

3233
/**
33-
* Whether Role-Based Access Control (RBAC) resources should be generated in the kubernetes manifests.
34+
* Whether Role-Based Access Control (RBAC) resources should be generated in the kubernetes
35+
* manifests.
3436
*/
3537
@ConfigItem(defaultValue = "false")
3638
public Boolean disableRbacGeneration;
3739

3840
/**
39-
* Whether the operator should be automatically started or not. Mostly useful for testing scenarios.
41+
* Whether the operator should be automatically started or not. Mostly useful for testing
42+
* scenarios.
4043
*/
4144
@ConfigItem
4245
public Optional<Boolean> startOperator;
46+
47+
/**
48+
* Whether the injected Kubernetes client should be stopped when the operator is stopped.
49+
*/
50+
@ConfigItem(defaultValue = "true")
51+
public Boolean closeClientOnStop;
52+
53+
/**
54+
* Whether the operator should stop if an informer error (such as one caused by missing / improper
55+
* RBACs) occurs during startup.
56+
*/
57+
@ConfigItem(defaultValue = "true")
58+
public Boolean stopOnInformerErrorDuringStartup;
4359
}

core/runtime/src/main/java/io/quarkiverse/operatorsdk/runtime/ConfigurationServiceRecorder.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public Supplier<QuarkusConfigurationService> configurationServiceSupplier(Versio
3333
.orElse(ConfigurationService.DEFAULT_RECONCILIATION_THREADS_NUMBER);
3434
final var timeout = runTimeConfiguration.terminationTimeoutSeconds
3535
.orElse(ConfigurationService.DEFAULT_TERMINATION_TIMEOUT_SECONDS);
36+
final var workflowThreads = runTimeConfiguration.concurrentWorkflowThreads
37+
.orElse(ConfigurationService.DEFAULT_WORKFLOW_EXECUTOR_THREAD_NUMBER);
38+
final var cacheSyncTimeout = runTimeConfiguration.cacheSyncTimeout;
3639

3740
configurations.forEach((name, c) -> {
3841
final var extConfig = runTimeConfiguration.controllers.get(name);
@@ -73,7 +76,8 @@ public Supplier<QuarkusConfigurationService> configurationServiceSupplier(Versio
7376
final var mapper = Serialization.jsonMapper();
7477
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
7578
final var container = Arc.container();
76-
container.select(ObjectMapperCustomizer.class, KubernetesClientSerializationCustomizer.Literal.INSTANCE)
79+
container.select(ObjectMapperCustomizer.class,
80+
KubernetesClientSerializationCustomizer.Literal.INSTANCE)
7781
.stream()
7882
.sorted()
7983
.forEach(c -> c.customize(mapper));
@@ -84,12 +88,16 @@ public Supplier<QuarkusConfigurationService> configurationServiceSupplier(Versio
8488
container.instance(KubernetesClient.class).get(),
8589
crdInfo,
8690
maxThreads,
91+
workflowThreads,
8792
timeout,
93+
cacheSyncTimeout,
8894
container.instance(Metrics.class).get(),
8995
shouldStartOperator(buildTimeConfiguration.startOperator, launchMode),
9096
mapper,
9197
container.instance(LeaderElectionConfiguration.class).orElse(null),
92-
container.instance(InformerStoppedHandler.class).orElse(null));
98+
container.instance(InformerStoppedHandler.class).orElse(null),
99+
buildTimeConfiguration.closeClientOnStop,
100+
buildTimeConfiguration.stopOnInformerErrorDuringStartup);
93101
};
94102
}
95103

core/runtime/src/main/java/io/quarkiverse/operatorsdk/runtime/QuarkusConfigurationService.java

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.quarkiverse.operatorsdk.runtime;
22

3+
import java.time.Duration;
34
import java.util.Collection;
45
import java.util.Collections;
56
import java.util.HashMap;
@@ -37,16 +38,23 @@ public class QuarkusConfigurationService extends AbstractConfigurationService {
3738
private final boolean startOperator;
3839
private final LeaderElectionConfiguration leaderElectionConfiguration;
3940
private final InformerStoppedHandler informerStoppedHandler;
41+
private final boolean closeClientOnStop;
42+
private final boolean stopOnInformerErrorDuringStartup;
43+
private final int concurrentWorkflowExecutorThreads;
44+
private final Duration cacheSyncTimeout;
4045

4146
@SuppressWarnings({ "rawtypes", "unchecked" })
4247
public QuarkusConfigurationService(
4348
Version version,
4449
Collection<QuarkusControllerConfiguration> configurations,
4550
KubernetesClient client,
46-
CRDGenerationInfo crdInfo, int maxThreads,
47-
int timeout, Metrics metrics, boolean startOperator, ObjectMapper mapper,
48-
LeaderElectionConfiguration leaderElectionConfiguration, InformerStoppedHandler informerStoppedHandler) {
51+
CRDGenerationInfo crdInfo, int maxThreads, int maxWorflowThreads,
52+
int timeout, Duration cacheSyncTimeout, Metrics metrics, boolean startOperator, ObjectMapper mapper,
53+
LeaderElectionConfiguration leaderElectionConfiguration, InformerStoppedHandler informerStoppedHandler,
54+
boolean closeClientOnStop, boolean stopOnInformerErrorDuringStartup) {
4955
super(version);
56+
this.closeClientOnStop = closeClientOnStop;
57+
this.stopOnInformerErrorDuringStartup = stopOnInformerErrorDuringStartup;
5058
final var cloner = new Cloner() {
5159
@Override
5260
public <R extends HasMetadata> R clone(R r) {
@@ -62,17 +70,21 @@ public <R extends HasMetadata> R clone(R r) {
6270
this.client = client;
6371
this.metrics = metrics;
6472
if (configurations != null && !configurations.isEmpty()) {
65-
reconcilerClassToName = new HashMap<>(configurations.size());
73+
final var size = configurations.size();
74+
reconcilerClassToName = new HashMap<>(size);
6675
configurations.forEach(c -> {
67-
reconcilerClassToName.put(c.getAssociatedReconcilerClassName(), c.getName());
76+
final var name = c.getName();
77+
reconcilerClassToName.put(c.getAssociatedReconcilerClassName(), name);
6878
register(c);
6979
});
7080
} else {
7181
reconcilerClassToName = Collections.emptyMap();
7282
}
7383
this.crdInfo = crdInfo;
7484
this.concurrentReconciliationThreads = maxThreads;
85+
this.concurrentWorkflowExecutorThreads = maxWorflowThreads;
7586
this.terminationTimeout = timeout;
87+
this.cacheSyncTimeout = cacheSyncTimeout;
7688
this.informerStoppedHandler = informerStoppedHandler;
7789
this.leaderElectionConfiguration = leaderElectionConfiguration;
7890
}
@@ -166,4 +178,24 @@ public Optional<LeaderElectionConfiguration> getLeaderElectionConfiguration() {
166178
public Optional<InformerStoppedHandler> getInformerStoppedHandler() {
167179
return Optional.ofNullable(informerStoppedHandler);
168180
}
181+
182+
@Override
183+
public int concurrentWorkflowExecutorThreads() {
184+
return concurrentWorkflowExecutorThreads;
185+
}
186+
187+
@Override
188+
public boolean closeClientOnStop() {
189+
return closeClientOnStop;
190+
}
191+
192+
@Override
193+
public boolean stopOnInformerErrorDuringStartup() {
194+
return stopOnInformerErrorDuringStartup;
195+
}
196+
197+
@Override
198+
public Duration cacheSyncTimeout() {
199+
return cacheSyncTimeout;
200+
}
169201
}

core/runtime/src/main/java/io/quarkiverse/operatorsdk/runtime/QuarkusControllerConfiguration.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ public DefaultRateLimiter(Duration refreshPeriod, int limitForPeriod) {
9191
private boolean namespaceExpansionRequired;
9292
@IgnoreProperty
9393
private List<DependentResourceSpec> dependentResources;
94-
9594
private Retry retry;
96-
9795
private RateLimiter rateLimiter;
9896

9997
@RecordableConstructor

core/runtime/src/main/java/io/quarkiverse/operatorsdk/runtime/RunTimeOperatorConfiguration.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515
package io.quarkiverse.operatorsdk.runtime;
1616

17+
import java.time.Duration;
1718
import java.util.List;
1819
import java.util.Map;
1920
import java.util.Optional;
@@ -49,4 +50,17 @@ public class RunTimeOperatorConfiguration {
4950
*/
5051
@ConfigItem
5152
public Optional<List<String>> namespaces;
53+
54+
/**
55+
* The max number of concurrent workflow processing requests.
56+
*/
57+
@ConfigItem
58+
public Optional<Integer> concurrentWorkflowThreads;
59+
60+
/**
61+
* How long the operator will wait for informers to finish synchronizing their caches on startup
62+
* before timing out.
63+
*/
64+
@ConfigItem(defaultValue = "2M")
65+
public Duration cacheSyncTimeout;
5266
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<name>Quarkus - Operator SDK - Parent</name>
1414
<properties>
1515
<quarkus.version>2.14.1.Final</quarkus.version>
16-
<java-operator-sdk.version>4.1.2</java-operator-sdk.version>
16+
<java-operator-sdk.version>4.1.3-SNAPSHOT</java-operator-sdk.version>
1717
</properties>
1818

1919
<repositories>

0 commit comments

Comments
 (0)