Skip to content

Commit dca45df

Browse files
committed
refactor: cleanup shutdown hook registration method documentation
Signed-off-by: Chris Laprun <metacosm@gmail.com>
1 parent 5c52b63 commit dca45df

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

  • operator-framework-core/src/main/java/io/javaoperatorsdk/operator

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,22 @@ protected ConfigurationService initConfigurationService(
137137
* <p>Note that you might want to tune "terminationGracePeriodSeconds" for the Pod running the
138138
* controller.
139139
*
140-
* @param gracefulShutdownTimeout timeout to wait for executor threads to complete actual
141-
* reconciliations
140+
* @param gracefulShutdownTimeout ignored, configure {@link
141+
* ConfigurationService#reconciliationTerminationTimeout()} instead
142+
* @deprecated Use {@link #installShutdownHook()} instead
142143
*/
143144
@SuppressWarnings("unused")
145+
@Deprecated(forRemoval = true)
144146
public void installShutdownHook(Duration gracefulShutdownTimeout) {
147+
installShutdownHook();
148+
}
149+
150+
/**
151+
* Adds a shutdown hook that automatically calls {@link #stop()} when the app shuts down. Note
152+
* that graceful shutdown is usually not needed, but some {@link Reconciler} implementations might
153+
* require it.
154+
*/
155+
public void installShutdownHook() {
145156
if (!leaderElectionManager.isLeaderElectionEnabled()) {
146157
Runtime.getRuntime().addShutdownHook(new Thread(this::stop));
147158
} else {
@@ -188,6 +199,10 @@ public synchronized void start() {
188199
}
189200
}
190201

202+
/**
203+
* Gracefully shuts down the operator, using the timeout defined by {@link
204+
* ConfigurationService#reconciliationTerminationTimeout()} to wait for reconciliations to finish.
205+
*/
191206
@Override
192207
public void stop() throws OperatorException {
193208
Duration reconciliationTerminationTimeout =

0 commit comments

Comments
 (0)