Skip to content

Commit 2633bcd

Browse files
authored
Merge pull request #1626 from aaruna/latchCountdownFixControllerManager
Add more debug/error logs and ensure controllerManager shutdown in case of exception
2 parents e3340e8 + 4968c6a commit 2633bcd

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

extended/src/main/java/io/kubernetes/client/extended/controller/ControllerManager.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,24 @@ public void run() {
6161
for (Controller controller : this.controllers) {
6262
controllerThreadPool.submit(
6363
() -> {
64-
controller.run();
65-
latch.countDown();
64+
try {
65+
log.debug("Starting controller manager");
66+
controller.run();
67+
} catch (Throwable t) {
68+
log.error("Unexpected controller termination", t);
69+
} finally {
70+
latch.countDown();
71+
log.debug("Exiting controller manager");
72+
}
6673
});
6774
}
6875
try {
69-
log.debug("Controller-Manager {} bootstrapping..");
76+
log.debug("Controller-Manager bootstrapping.");
7077
latch.await();
7178
} catch (InterruptedException e) {
7279
log.error("Aborting controller-manager.", e);
7380
} finally {
74-
log.info("Controller-Manager {} exited");
81+
log.info("Controller-Manager exited");
7582
}
7683
}
7784
}

extended/src/main/java/io/kubernetes/client/extended/controller/DefaultController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ public void run() {
154154
this.worker();
155155
} catch (Throwable t) {
156156
log.error("Unexpected controller loop abortion", t);
157+
} finally {
158+
latch.countDown();
159+
log.debug("Exiting controller {} worker {}..", this.name, workerIndex);
157160
}
158-
latch.countDown();
159-
log.debug("Exiting controller {} worker {}..", this.name, workerIndex);
160161
},
161162
0,
162163
1,

0 commit comments

Comments
 (0)