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
kubelet: pod should be terminated immediately once preStop complete #24695
Comments
PreStop hooks are indeed mostly used for shutting down the applications gracefully, but I'm not sure whether there are other use cases out there. Changing this could potentially break those users. /cc @kubernetes/sig-node @smarterclayton |
You shouldn't have to wait five minutes - are you eating SIGTERM in your main process? If you handle SIGTERM correctly then when Prestop returns you'll be signaled immediately. So having to wait five minutes sounds like either Prestop isn't exiting correctly or your process isn't listening for term. Prestop isn't intended to allow you to escape the graceful shutdown quota. It's a contract with the rest of the system. |
@smarterclayton I have not eaten the SIGTERM, but can not terminate pod after PreStop return. $ cat nginx.term.json $kubectl create -f nginx.term.json $kubectl delete po nginx-m5pbz $# kubectl get po |
I don't think "service nginx start" in bash will proxy the SIGTERM we
send to bash (which is the parent process). You'll need to add a trap
handler to your bash script in command and "service nginx stop".
|
@smarterclayton As your suggestion, I changed my RC profile, add it works well. Thanks. $ cat Dockerfile $ cat bootstrap.sh my_exit() while : $ cat term.json |
I am not sure how this works ??! Is the trap handled in the preStop(within the commands/script running in preStop) or outside preStop ? Please help ! |
I have a RC with 5 pods. preStop.sh is defined to process all requests before shutdown the service in container. preStop.sh takes almost 2min generally, or 5min at most. So I should set "terminationGracePeriodSeconds": 300 for a graceful termination.
I MUST wait for 5min no matter whether the preStop.sh is completed. when I use rolling update for all 5 pods, it takes 5min*5 = 25min.
Terminate pod immediately if preStop is configured and completed. So in most cases, the rolling update will just spend 10min. In my opinion, preStop is used to graceful termination, so there is no need to wait a fixed terminationGracePeriodSeconds time.
Just set 'gracePeriod = 0'.
https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/dockertools/manager.go?#L1345
I will send a PR if it is OK.
The text was updated successfully, but these errors were encountered: