Skip to content

Commit 94f1591

Browse files
committed
Operator API change
1 parent 6b3d0f7 commit 94f1591

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,24 @@ public Operator(KubernetesClient kubernetesClient, ConfigurationService configur
7777
.ifPresent(c -> leaderElectionManager.init(c, this.kubernetesClient));
7878
}
7979

80+
/**
81+
* Uses {@link ConfigurationService#getTerminationTimeoutSeconds()} for graceful shutdown timeout
82+
*/
83+
@Deprecated(forRemoval = true)
84+
public void installShutdownHook() {
85+
installShutdownHook(
86+
Duration.ofSeconds(ConfigurationServiceProvider.instance().getTerminationTimeoutSeconds()));
87+
}
88+
8089
/**
8190
* Adds a shutdown hook that automatically calls {@link #stop()} when the app shuts down.
8291
*
83-
* @deprecated This feature should not be used anymore
92+
* @param gracefulShutdownTimeout - timeout to wait for executor threads to complete actual
93+
* reconciliations
8494
*/
85-
public void installShutdownHook() {
95+
public void installShutdownHook(Duration gracefulShutdownTimeout) {
8696
if (!leaderElectionManager.isLeaderElectionEnabled()) {
87-
Runtime.getRuntime().addShutdownHook(new Thread(this::stop));
97+
Runtime.getRuntime().addShutdownHook(new Thread(() -> stop(gracefulShutdownTimeout)));
8898
} else {
8999
log.warn("Leader election is on, shutdown hook will not be installed.");
90100
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ public HasMetadata clone(HasMetadata object) {
121121
*
122122
* @return the number of seconds to wait before terminating reconciliation threads
123123
*/
124+
@Deprecated(forRemoval = true)
124125
default int getTerminationTimeoutSeconds() {
125126
return DEFAULT_TERMINATION_TIMEOUT_SECONDS;
126127
}

0 commit comments

Comments
 (0)