| Summary: | PreStop hooks are no longer blocking | ||||||
|---|---|---|---|---|---|---|---|
| Product: | OpenShift Container Platform | Reporter: | Matt Wringe <mwringe> | ||||
| Component: | Node | Assignee: | Avesh Agarwal <avagarwa> | ||||
| Status: | CLOSED NOTABUG | QA Contact: | DeShuai Ma <dma> | ||||
| Severity: | unspecified | Docs Contact: | |||||
| Priority: | unspecified | ||||||
| Version: | 3.3.0 | CC: | aos-bugs, ccoleman, decarr, jokerman, mmccomas, mwringe | ||||
| Target Milestone: | --- | ||||||
| Target Release: | --- | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |||||
| Doc Text: | Story Points: | --- | |||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2016-09-01 19:12:36 UTC | Type: | Bug | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Attachments: |
|
||||||
|
Description
Matt Wringe
2016-09-01 16:51:55 UTC
Matt - is there a sample pod yaml that you can provide? Avesh - can you attempt to reproduce? see step5: http://kubernetes.io/docs/user-guide/pods/#termination-of-pods this is probably expected behavior (30 seconds + 2 seconds) Working on reproducing this. Yes a sample pod yaml if available would help. Created attachment 1196910 [details]
sample pod template with rc
Sample pod template is attached. Note that a SIGTERM is suppose to be applied to the script after 30 seconds, but not a SIGKILL. The script traps the SIGTERM and should prevents it from terminating the script. This pod should essentially not be stoppable from OpenShift, if you want to stop it you would then need to manually kill it with Docker. I think I am able to reproduce it as follows:
1. I modified the provided yaml to make it work with kube.
#cat test-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: prestop-test
spec:
containers:
- image: mwringe/prestop-test:latest
name: prestop-test
lifecycle:
preStop:
exec:
command:
- "/tmp/prestop.sh"
2. Created the pod: kubectl create -f test-pod.yaml
3. Once the pod was running successfully, I deleted the pod explicitly:
kubectl delete -f test-pod.yaml
And I see that after certain time, the pod is disappeared. So it does not block ok preStop script.
But as what Derek provided the link: http://kubernetes.io/docs/user-guide/pods/#termination-of-pods
It clearly says that the only difference with having prestop hooks is that
grace period is extended by 2 more seconds if needed, it does not say anything
about blocking on prestop hooks. So it seems to be working as expected.
This is working as designed. Allowing a pod to block deletion on a preStop hook would be a denial of service attack. There is no event returned to the user when their preStop hook exceeds their grace-period, while there is an event generated when their hook fails. We should unify the behavior to provide an event in either criteria. Opened https://github.com/kubernetes/kubernetes/issues/31902 to track generation of an event in future release, but closing this as not a bug. Preventing deletion of pods is exactly what the preStop hook is suppose to do and is how it used to work. The postStart scripts also prevented pods from being deleted until the postStart script passed as well. This is a regression from past behaviour in 3.1 This is the designed behavior of the system - the docs are wrong. The system does not allow unbounded execution of any component, including pods. Set gracePeriod to a long enough duration to allow your handler to complete. |