<p>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.</p>
<p>Let us say that we set <code>terminationGracePeriodSeconds</code> to 3600 seconds. After the completion of the preStop hook, shouldn't it now send the <code>TERM</code> signal to my processes, and wait until the expiry of <code>terminationGracePeriodSeconds</code> before finally sending the <code>KILL</code> signal?</p>
<p>Because now it seems that after the completion of the preStop hook, it immediately sends a <code>KILL</code> signal and my pod is deleted abruptly, even when there is still a process running.</p>

overflow_warrior_27
<p>No, it won't wait for the <code>terminationGracePeriodSeconds</code>.</p>
<p>This is the intended behavior for the <code>preStop</code> hook to send a <code>SIGTERM</code> on completion.</p>
<p>In case the <code>preStop</code> hook isn't finished after <code>terminationGracePeriodSeconds</code> countdown, kubelet will request 2 extra seconds for it to complete and then will  send a <code>SIGKILL</code> to force the pod to shutdown.</p>
<p>The full sequence is :</p>
<ol>
<li>pod deletion has been requested</li>
<li><code>preStop</code> hook kicks in and <code>terminationGracePeriodSeconds</code> countdown starts :
<ul>
<li>if <code>preStop</code> hook completes, it sends a <code>SIGTERM</code> <strong>which stops the pods</strong></li>
<li>if <code>preStop</code> hook isn't finished within <code>terminationGracePeriodSeconds</code> countdown, kubelet request 2 extra seconds before sending the <code>SIGKILL</code> <strong>which will stops the pod</strong>.</li>
</ul>
</li>
</ol>
<p><a href="https://i.stack.imgur.com/COzGE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/COzGE.png" alt="enter image description here" /></a></p>
<p>Sources :</p>
<ul>
<li><a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination</a></li>
<li><a href="https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/</a></li>
</ul>
