Clarify PreStop hook behaviour
This commit is contained in:
@@ -36,10 +36,12 @@ No parameters are passed to the handler.
|
|||||||
|
|
||||||
`PreStop`
|
`PreStop`
|
||||||
|
|
||||||
This hook is called immediately before a container is terminated due to an API request or management event such as liveness probe failure, preemption, resource contention and others. A call to the preStop hook fails if the container is already in terminated or completed state.
|
This hook is called immediately before a container is terminated due to an API request or management
|
||||||
It is blocking, meaning it is synchronous,
|
event such as a liveness/startup probe failure, preemption, resource contention and others. This
|
||||||
so it must complete before the signal to stop the container can be sent.
|
hook is not called if the container crashes or exits. The Pod's termination grace period countdown
|
||||||
No parameters are passed to the handler.
|
begins before the `PreStop` hook is executed. Regardless of the outcome of the handler, the
|
||||||
|
container will eventually terminate within the Pod's termination grace period. No parameters are
|
||||||
|
passed to the handler.
|
||||||
|
|
||||||
A more detailed description of the termination behavior can be found in
|
A more detailed description of the termination behavior can be found in
|
||||||
[Termination of Pods](/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination).
|
[Termination of Pods](/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination).
|
||||||
@@ -65,19 +67,15 @@ the Container ENTRYPOINT and hook fire asynchronously.
|
|||||||
However, if the hook takes too long to run or hangs,
|
However, if the hook takes too long to run or hangs,
|
||||||
the Container cannot reach a `running` state.
|
the Container cannot reach a `running` state.
|
||||||
|
|
||||||
`PreStop` hooks are not executed asynchronously from the signal
|
`PreStop` hooks are not executed asynchronously from the signal to stop the Container; the hook must
|
||||||
to stop the Container; the hook must complete its execution before
|
complete its execution before the TERM signal can be sent. If a `PreStop` hook hangs during
|
||||||
the signal can be sent.
|
execution, the Pod's phase will be `Terminating` and remain there until the Pod is killed after its
|
||||||
If a `PreStop` hook hangs during execution,
|
`terminationGracePeriodSeconds` expires. This grace period applies to the total time it takes for
|
||||||
the Pod's phase will be `Terminating` and remain there until the Pod is
|
both the `PreStop` hook to execute and for the Container to stop normally. If, for example,
|
||||||
killed after its `terminationGracePeriodSeconds` expires.
|
`terminationGracePeriodSeconds` is 60, and the hook takes 55 seconds to complete, and the Container
|
||||||
This grace period applies to the total time it takes for both
|
takes 10 seconds to stop normally after receiving the signal, then the Container will be killed
|
||||||
the `PreStop` hook to execute and for the Container to stop normally.
|
before it can stop normally, since `terminationGracePeriodSeconds` is less than the total time
|
||||||
If, for example, `terminationGracePeriodSeconds` is 60, and the hook
|
(55+10) it takes for these two things to happen.
|
||||||
takes 55 seconds to complete, and the Container takes 10 seconds to stop
|
|
||||||
normally after receiving the signal, then the Container will be killed
|
|
||||||
before it can stop normally, since `terminationGracePeriodSeconds` is
|
|
||||||
less than the total time (55+10) it takes for these two things to happen.
|
|
||||||
|
|
||||||
If either a `PostStart` or `PreStop` hook fails,
|
If either a `PostStart` or `PreStop` hook fails,
|
||||||
it kills the Container.
|
it kills the Container.
|
||||||
|
|||||||
Reference in New Issue
Block a user