<p>I have a problem.
There is preStop option in manifest file and OOMKilled was happened.
pod was restarted but no heapdump is created.</p>
<p>lifecycle:
preStop:
exec:
command: [&quot;/tmp/preStop.sh&quot;]</p>
<p>heapdump works when I manually terminate the pod.</p>
<p>so I wonder if pod is restarted, preStop is not supposed to be executed?</p>
<p>I thought when pod is restarted, first send TermSignal to application and execute preStop and terminate and start pod again. Am I wrong?</p>
<p>Thanks
Best Regards.</p>

user2286858
<blockquote>
<p>when the pod is restarted, first send TermSignal to the application
and execute preStop and terminate and start pod again. Am I wrong?</p>
</blockquote>
<p>As per the official <a href="https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks" rel="nofollow noreferrer">documentation</a></p>
<blockquote>
<p><code>PreStop</code> hooks are not executed asynchronously from the signal to
stop the Container; the hook must complete its execution before the
<strong>TERM</strong> signal can be sent.</p>
<p>If a <code>PreStop</code> hook hangs during execution, the Pod's phase will be
<strong>Terminating</strong> and remain there until the Pod is killed after its <code>terminationGracePeriodSeconds</code> expires. This grace period applies to
the total time it takes for both the PreStop hook to execute and for
the Container to stop normally.</p>
</blockquote>
<p>Hope the above information is useful to you.</p>
