Skip to content

Commit 5ac3253

Browse files
committed
Fix wait for death
1 parent b6a9f6e commit 5ac3253

File tree

1 file changed

+12
-2
lines changed
  • operator/src/main/java/oracle/kubernetes/operator

1 file changed

+12
-2
lines changed

operator/src/main/java/oracle/kubernetes/operator/Main.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.concurrent.ConcurrentMap;
2626
import java.util.concurrent.ExecutionException;
2727
import java.util.concurrent.ScheduledExecutorService;
28+
import java.util.concurrent.Semaphore;
2829
import java.util.concurrent.ThreadFactory;
2930
import java.util.concurrent.TimeUnit;
3031
import java.util.concurrent.atomic.AtomicBoolean;
@@ -128,7 +129,6 @@ public Thread newThread(Runnable r) {
128129

129130
private static String principal;
130131
private static RestServer restServer = null;
131-
private static Thread livenessThread = null;
132132
private static KubernetesVersion version = null;
133133

134134
static final String READINESS_PROBE_FAILURE_EVENT_FILTER =
@@ -438,10 +438,20 @@ private static void startLivenessThread() {
438438
wrappedExecutorService.scheduleWithFixedDelay(new OperatorLiveness(), 5, 5, TimeUnit.SECONDS);
439439
}
440440

441+
private static final Semaphore shutdownSignal = new Semaphore(0);
442+
441443
private static void waitForDeath() {
444+
Runtime.getRuntime()
445+
.addShutdownHook(
446+
new Thread() {
447+
@Override
448+
public void run() {
449+
shutdownSignal.release();
450+
}
451+
});
442452

443453
try {
444-
livenessThread.join();
454+
shutdownSignal.acquire();
445455
} catch (InterruptedException ignore) {
446456
// ignoring
447457
}

0 commit comments

Comments
 (0)