I have a preStop hook for my pod that sends TSTP signals to each process, and waits for their completion, but only to a maximum of 60 seconds.
Let us say that we set terminationGracePeriodSeconds to 3600 seconds. After the completion of the preStop hook, shouldn't it now send the TERM signal to my processes, and wait until the expiry of terminationGracePeriodSeconds before finally sending the KILL signal?
Because now it seems that after the completion of the preStop hook, it immediately sends a KILL signal and my pod is deleted abruptly, even when there is still a process running.
No, it won't wait for the
terminationGracePeriodSeconds.This is the intended behavior for the
preStophook to send aSIGTERMon completion.In case the
preStophook isn't finished afterterminationGracePeriodSecondscountdown, kubelet will request 2 extra seconds for it to complete and then will send aSIGKILLto force the pod to shutdown.The full sequence is :
preStophook kicks in andterminationGracePeriodSecondscountdown starts :preStophook completes, it sends aSIGTERMwhich stops the podspreStophook isn't finished withinterminationGracePeriodSecondscountdown, kubelet request 2 extra seconds before sending theSIGKILLwhich will stops the pod.Sources :