java
java copied to clipboard
Leader Elector shutdown delegated controller beside it cannot re-elect after renew failed
Similar to https://github.com/kubernetes-client/java/issues/714 I found that the controller is also shutdown after the renew fails, so even if I loop the leaderElector.run(..) code the DefaultController.run() will do nothing because it will also end its worker loop .
Adding a while(..) loop in my own LeaderElectingController as suggested in this comment will not work at all.
The shutdown will make the delegateController useless.
while(continueLeadElection) {
this.leaderElector.run(
() -> {
log.info("Lease acquired, starting controller..");
this.delegateController.run();
},
() -> {
log.info("Lease lost, shutting down controller..");
this.delegateController.shutdown();
});
}
As you can see, using delegateController = DefaultController instance will call the shutdown() method, which will turn off the queue.
And, there is no way to re-activate the queue in case the old leader is elected again.
I suspect I will need to add the creation of my DefaultController instance in the loop process, but I am not sure if this is a good idea at all with all the pieces working underneath.