Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ public Operator(KubernetesClient kubernetesClient, ConfigurationService configur

/** Adds a shutdown hook that automatically calls {@link #stop()} when the app shuts down. */
public void installShutdownHook() {
Runtime.getRuntime().addShutdownHook(new Thread(this::stop));
if (!leaderElectionManager.isLeaderElectionEnabled()) {
Runtime.getRuntime().addShutdownHook(new Thread(this::stop));
} else {
log.warn("Leader election is on, shutdown hook will not be installed.");
}
}

public KubernetesClient getKubernetesClient() {
Expand Down Expand Up @@ -112,7 +116,6 @@ public void stop() throws OperatorException {
final var configurationService = ConfigurationServiceProvider.instance();
log.info(
"Operator SDK {} is shutting down...", configurationService.getVersion().getSdkVersion());

controllerManager.stop();
ExecutorServiceManager.stop();
leaderElectionManager.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import org.takes.http.Exit;
import org.takes.http.FtBasic;

import io.fabric8.kubernetes.client.*;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.javaoperatorsdk.operator.Operator;

public class WebPageOperator {
Expand Down