Skip to content

Commit d2f8b51

Browse files
committed
refactor: remove deprecated getTerminationTimeoutSeconds and associated (#2297)
Signed-off-by: Chris Laprun <[email protected]> Signed-off-by: Attila Mészáros <[email protected]>
1 parent b409b86 commit d2f8b51

File tree

5 files changed

+10
-45
lines changed

5 files changed

+10
-45
lines changed

Diff for: docs/documentation/v5-0-migration.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@ permalink: /docs/v5-0-migration
1818
now contains all the utility methods used for event sources naming that were previously defined in
1919
the `EventSourceInitializer` interface.
2020
3. Patching status through `UpdateControl` like the `patchStatus` method now by default
21-
uses Server Side Apply instead of simple patch. To use the former approach, use the feature flag
21+
uses Server Side Apply instead of simple patch. To use the former approach, use the feature flag
2222
in [`ConfigurationService`](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java#L400-L400)
2323
!!! IMPORTANT !!!
24-
Migration from a non-SSA based controller to SSA based controller can cause problems, due to known issues.
25-
See the following [integration test](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework/src/test/java/io/javaoperatorsdk/operator/StatusPatchSSAMigrationIT.java#L71-L82) where it is demonstrated.
26-
Also, the related part of a [workaround](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework/src/test/java/io/javaoperatorsdk/operator/StatusPatchSSAMigrationIT.java#L110-L116).
24+
Migration from a non-SSA based controller to SSA based controller can cause problems, due to known issues.
25+
See the
26+
following [integration test](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework/src/test/java/io/javaoperatorsdk/operator/StatusPatchSSAMigrationIT.java#L71-L82)
27+
where it is demonstrated. Also, the related part of
28+
a [workaround](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework/src/test/java/io/javaoperatorsdk/operator/StatusPatchSSAMigrationIT.java#L110-L116).
2729
4. `ManagedDependentResourceContext` has been renamed to `ManagedWorkflowAndDependentResourceContext` and is accessed
2830
via the accordingly renamed `managedWorkflowAndDependentResourceContext` method.
2931
5. `ResourceDiscriminator` was removed. In most of the cases you can just delete the discriminator, everything should
3032
work without it by default. To optimize and handle special cases see the relevant section in [Dependent Resource documentation](/docs/dependent-resources#multiple-dependent-resources-of-same-type).
33+
6. `ConfigurationService.getTerminationTimeoutSeconds` and associated overriding mechanism have been removed,
34+
use `Operator.stop(Duration)` instead.
35+
7. `Operator.installShutdownHook()` has been removed, use `Operator.installShutdownHook(Duration)` instead

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java

+1-11
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,6 @@ private static ConfigurationService initConfigurationService(KubernetesClient cl
9898
return ConfigurationService.newOverriddenConfigurationService(overrider);
9999
}
100100

101-
/**
102-
* Uses {@link ConfigurationService#getTerminationTimeoutSeconds()} for graceful shutdown timeout
103-
*
104-
* @deprecated use the overloaded version with graceful shutdown timeout parameter.
105-
*
106-
*/
107-
@Deprecated(forRemoval = true)
108-
public void installShutdownHook() {
109-
installShutdownHook(Duration.ofSeconds(configurationService.getTerminationTimeoutSeconds()));
110-
}
111-
112101
/**
113102
* Adds a shutdown hook that automatically calls {@link #stop()} when the app shuts down. Note
114103
* that graceful shutdown is usually not needed, but some {@link Reconciler} implementations might
@@ -120,6 +109,7 @@ public void installShutdownHook() {
120109
* @param gracefulShutdownTimeout timeout to wait for executor threads to complete actual
121110
* reconciliations
122111
*/
112+
@SuppressWarnings("unused")
123113
public void installShutdownHook(Duration gracefulShutdownTimeout) {
124114
if (!leaderElectionManager.isLeaderElectionEnabled()) {
125115
Runtime.getRuntime().addShutdownHook(new Thread(() -> stop(gracefulShutdownTimeout)));

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java

-16
Original file line numberDiff line numberDiff line change
@@ -185,22 +185,6 @@ default int minConcurrentWorkflowExecutorThreads() {
185185
return MIN_DEFAULT_WORKFLOW_EXECUTOR_THREAD_NUMBER;
186186
}
187187

188-
int DEFAULT_TERMINATION_TIMEOUT_SECONDS = 10;
189-
190-
/**
191-
* Retrieves the number of seconds the SDK waits for reconciliation threads to terminate before
192-
* shutting down.
193-
*
194-
* @deprecated use {@link io.javaoperatorsdk.operator.Operator#stop(Duration)} instead. Where the
195-
* parameter can be passed to specify graceful timeout.
196-
*
197-
* @return the number of seconds to wait before terminating reconciliation threads
198-
*/
199-
@Deprecated(forRemoval = true)
200-
default int getTerminationTimeoutSeconds() {
201-
return DEFAULT_TERMINATION_TIMEOUT_SECONDS;
202-
}
203-
204188
default Metrics getMetrics() {
205189
return Metrics.NOOP;
206190
}

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverrider.java

-11
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public class ConfigurationServiceOverrider {
2727
private Integer concurrentWorkflowExecutorThreads;
2828
private Integer minConcurrentWorkflowExecutorThreads;
2929
private Cloner cloner;
30-
private Integer timeoutSeconds;
3130
private Boolean closeClientOnStop;
3231
private KubernetesClient client;
3332
private ExecutorService executorService;
@@ -94,11 +93,6 @@ public ConfigurationServiceOverrider withResourceCloner(Cloner cloner) {
9493
return this;
9594
}
9695

97-
public ConfigurationServiceOverrider withTerminationTimeoutSeconds(int timeoutSeconds) {
98-
this.timeoutSeconds = timeoutSeconds;
99-
return this;
100-
}
101-
10296
public ConfigurationServiceOverrider withMetrics(Metrics metrics) {
10397
this.metrics = metrics;
10498
return this;
@@ -268,11 +262,6 @@ public int minConcurrentWorkflowExecutorThreads() {
268262
: original.minConcurrentWorkflowExecutorThreads();
269263
}
270264

271-
@Override
272-
public int getTerminationTimeoutSeconds() {
273-
return timeoutSeconds != null ? timeoutSeconds : original.getTerminationTimeoutSeconds();
274-
}
275-
276265
@Override
277266
public Metrics getMetrics() {
278267
return metrics != null ? metrics : original.getMetrics();

Diff for: operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java

-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ public <R extends HasMetadata> R clone(R object) {
6060
}
6161
})
6262
.withConcurrentReconciliationThreads(25)
63-
.withTerminationTimeoutSeconds(100)
6463
.withMetrics(new Metrics() {})
6564
.withLeaderElectionConfiguration(new LeaderElectionConfiguration("newLease", "newLeaseNS"))
6665
.withInformerStoppedHandler((informer, ex) -> {
@@ -72,8 +71,6 @@ public <R extends HasMetadata> R clone(R object) {
7271
overridden.checkCRDAndValidateLocalModel());
7372
assertNotEquals(config.concurrentReconciliationThreads(),
7473
overridden.concurrentReconciliationThreads());
75-
assertNotEquals(config.getTerminationTimeoutSeconds(),
76-
overridden.getTerminationTimeoutSeconds());
7774
assertNotEquals(config.getExecutorService(), overridden.getExecutorService());
7875
assertNotEquals(config.getWorkflowExecutorService(), overridden.getWorkflowExecutorService());
7976
assertNotEquals(config.getMetrics(), overridden.getMetrics());

0 commit comments

Comments
 (0)