kubernetesrestartheap-dump

kubernetes didn't create heapdump when pod is restarted


I have a problem. There is preStop option in manifest file and OOMKilled was happened. pod was restarted but no heapdump is created.

lifecycle: preStop: exec: command: ["/tmp/preStop.sh"]

heapdump works when I manually terminate the pod.

so I wonder if pod is restarted, preStop is not supposed to be executed?

I thought when pod is restarted, first send TermSignal to application and execute preStop and terminate and start pod again. Am I wrong?

Thanks Best Regards.


Solution

  • This is a known behavior for OOMKilled pods to not invoke preStop hook.

    As explained by Chanpreet08 (GitHub user)

    K8 gives SIGTERM signal if it wants to terminate the pod, but in case of OOM, it passes SIGKILL to the pod which instantly kills the main process and finally terminates the pod without waiting for the prestop to execute. So in case of OOM, the prestop won;t execute.

    https://github.com/kubernetes/kubernetes/issues/93818