Skip to content

fix: leader election stop deadlock #1618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 24, 2022
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