kubernetes: kubelet does not honor shortened grace period on already-deleting pod
What happened:
Delete a pod with a grace period of 120 seconds, then again with 60 seconds. It will still wait until the first 120 time elapses to delete the pod.
What you expected to happen:
For it to use the new grace period of 60 seconds
How to reproduce it (as minimally and precisely as possible):
ben@shadowfax:~$ kubectl get pod -o yaml | egrep -i 'term|del'
blockOwnerDeletion: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
terminationGracePeriodSeconds: 900
ben@shadowfax:~$ kubectl delete pod $(kubectl get pods | grep python | grep Running | cut -f1 -d' ') --grace-period=60
pod "python-645896764c-f5p9k" deleted
ben@shadowfax:~$ kubectl get pod -o yaml | egrep -i 'term|del'
blockOwnerDeletion: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
terminationGracePeriodSeconds: 900
deletionGracePeriodSeconds: 60
deletionTimestamp: "2019-10-02T16:27:50Z"
blockOwnerDeletion: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
terminationGracePeriodSeconds: 900
ben@shadowfax:~$ kubectl delete pod $(kubectl get pods | grep python | grep Running | cut -f1 -d' ') --grace-period=10
pod "python-645896764c-cfsjz" deleted
ben@shadowfax:~$ kubectl get pod -o yaml | egrep -i 'term|del'
blockOwnerDeletion: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
terminationGracePeriodSeconds: 900
deletionGracePeriodSeconds: 10
deletionTimestamp: "2019-10-02T16:27:15Z"
blockOwnerDeletion: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
terminationGracePeriodSeconds: 900
deletionGracePeriodSeconds: 60
deletionTimestamp: "2019-10-02T16:27:50Z"
blockOwnerDeletion: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
terminationGracePeriodSeconds: 900
Environment:
- Kubernetes version (use
kubectl version): 1.14 - Cloud provider or hardware configuration: Rancher/RKE/Hyperkube
- OS (e.g:
cat /etc/os-release): Ubuntu 18.04 - Install tools: RKE/Rancher
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 1
- Comments: 18 (13 by maintainers)
We run into this while writing an E2E test (#121491) for Job that does the following:
step 4 doesn’t have any effect because of this issue. Note that Pods that belong to Jobs have finalizers, so it wouldn’t be immediately deleted from the apiserver. This would be useful so that we don’t have to wait for the pod to reach the grace period.
For now, we just shortened the grace period to a value that we hope would prevent flakes: 5s.
/assign
This is something I’m working on with #113606
/triage accepted In progress PR https://github.com/kubernetes/kubernetes/pull/98507