-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Force deleting pods not working after deletionGracePeriodSeconds set to a negative value #98506
Comments
/sig api-machinery |
@jqmichael: The label(s) In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/assign |
/cc @jiahuif |
No component in the system should ever treat the timestamp of DeletionTimestamp as authoritative. In Kube, components are required to calculate the time period from when they observe the event in their local clock (i.e. 30s from now), not use the deletion timestamp. A negative value of deletion grace period should be rejected by the apiserver as an invalid value (bad request / invalid field). |
attempts to take a missing or positive deletion grace period negative should be rejected, I agree. if a negative value is already persisted, I'd be inclined to allow a negative value in an update and clip to 0 |
As I mentioned in the PR, eviction is passing negatives through to the store: https://github.com/kubernetes/kubernetes/blob/master/pkg/registry/core/pod/storage/eviction.go#L160 In kubectl, we specify the default value for GracePeriod is -1. In the case of delete, we simply don't set the value in the deleteOptions we send to the API. In the case of eviction, we send the -1 value, and that gets passed along to the store. |
I don't see the -1 getting sent to the eviction API. It looks like values < 0 result in a nil value being sent to the API: kubernetes/staging/src/k8s.io/kubectl/pkg/drain/drain.go Lines 136 to 140 in 4225e1f
I would not expect the API to accept a negative value as-is. |
Looks like you are correct. Do the deletionOptions go through their own validation or through some kind of validation for the evict API? The original bug report mentions 'evict' though it's not clear if the eviction API was used or not. |
ValidateDeleteOptions is called inside pod deletion, but did not check that the field was non-negative. I don't see any eviction-specific validation. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-contributor-experience at kubernetes/community. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-contributor-experience at kubernetes/community. |
/lifecycle rotten |
@wzshiming Im investigating the |
What happened:
Some k8s client tried to evict a pod by setting negative value for deletionGracePeriodSeconds. But all eventual delete calls (and force-delete calls) made by kubelet, pod-garbage-collector, etc were not able to delete that pod, because apiserver doesnt allow deletionGracePeriodSeconds to be increased once it is set. So force-delete (which set it to 0) doesn't take effect when it's already negative. Not even kubectl is able to call delete with negative grace-period. But curl with an even more negative grace-period value worked.
What you expected to happen:
force-delete works.
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
I think the issue is in the code below
https://github.com/kubernetes/apiserver/blame/d4c9a195921609cf81e3e950beaf246f934e0f4c/pkg/registry/rest/delete.go#L96-L110
As the comment suggest, in phase 1, the
DeletionGracePeriodSeconds
was set to a negative value (meaningDeletionTimestamp
was in the past), and in phase 2,options.GracePeriodSeconds
has to be set even lower, otherwise, it will be considered as pending graceful deletion and not performing the immediate delete.I think there're two possible fixes.
DeletionTimestamp
in the past (DeletionGracePeriodSeconds
should be non-negative). In that case, we could convertoptions.GracePeriodSeconds
to 0 if negative.DeletionTimestamp
could be set in the past. In that case, in phase 2, we treat negative value ofobjectMeta.GetDeletionGracePeriodSeconds()
the same as 0, and allow immediate delete.Thoughts?
Environment:
kubectl version
):cat /etc/os-release
):uname -a
):The text was updated successfully, but these errors were encountered: