Skip to content

Commit 3a21fe1

Browse files
committed
refactor: remove deprecated getTerminationTimeoutSeconds and associated
Signed-off-by: Chris Laprun <[email protected]>
1 parent 5842721 commit 3a21fe1

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,11 +18,16 @@ 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.
31+
5. `ConfigurationService.getTerminationTimeoutSeconds` and associated overriding mechanism have been removed,
32+
use `Operator.stop(Duration)` instead.
33+
6. `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
@@ -170,22 +170,6 @@ default int minConcurrentWorkflowExecutorThreads() {
170170
return MIN_DEFAULT_WORKFLOW_EXECUTOR_THREAD_NUMBER;
171171
}
172172

173-
int DEFAULT_TERMINATION_TIMEOUT_SECONDS = 10;
174-
175-
/**
176-
* Retrieves the number of seconds the SDK waits for reconciliation threads to terminate before
177-
* shutting down.
178-
*
179-
* @deprecated use {@link io.javaoperatorsdk.operator.Operator#stop(Duration)} instead. Where the
180-
* parameter can be passed to specify graceful timeout.
181-
*
182-
* @return the number of seconds to wait before terminating reconciliation threads
183-
*/
184-
@Deprecated(forRemoval = true)
185-
default int getTerminationTimeoutSeconds() {
186-
return DEFAULT_TERMINATION_TIMEOUT_SECONDS;
187-
}
188-
189173
default Metrics getMetrics() {
190174
return Metrics.NOOP;
191175
}

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

-11
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public class ConfigurationServiceOverrider {
2626
private Integer concurrentWorkflowExecutorThreads;
2727
private Integer minConcurrentWorkflowExecutorThreads;
2828
private Cloner cloner;
29-
private Integer timeoutSeconds;
3029
private Boolean closeClientOnStop;
3130
private KubernetesClient client;
3231
private ExecutorService executorService;
@@ -91,11 +90,6 @@ public ConfigurationServiceOverrider withResourceCloner(Cloner cloner) {
9190
return this;
9291
}
9392

94-
public ConfigurationServiceOverrider withTerminationTimeoutSeconds(int timeoutSeconds) {
95-
this.timeoutSeconds = timeoutSeconds;
96-
return this;
97-
}
98-
9993
public ConfigurationServiceOverrider withMetrics(Metrics metrics) {
10094
this.metrics = metrics;
10195
return this;
@@ -236,11 +230,6 @@ public int minConcurrentWorkflowExecutorThreads() {
236230
: original.minConcurrentWorkflowExecutorThreads();
237231
}
238232

239-
@Override
240-
public int getTerminationTimeoutSeconds() {
241-
return timeoutSeconds != null ? timeoutSeconds : original.getTerminationTimeoutSeconds();
242-
}
243-
244233
@Override
245234
public Metrics getMetrics() {
246235
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)