python icon indicating copy to clipboard operation
python copied to clipboard

Add "force" option to delete pods stuck in Terminating state

Open whummer opened this issue 8 years ago • 10 comments

The kubectl CLI has a --force delete option which is useful to force-delete pods that are stuck in a Terminating state:

kubectl delete --force --grace-period=0 po/mypod1

There is a grace_period_seconds option, but I wasn't able to find a force option in the API of the python client - perhaps I'm missing something? Thanks

whummer avatar Apr 11 '18 14:04 whummer

+1 - does not appear to be a force option for deleting pods in the Python API, would seem necessary

nimbixler avatar Jun 06 '18 00:06 nimbixler

+1 - Our k8s tooling would really like to see this feature implemented

mgarod avatar Jun 28 '18 14:06 mgarod

--force flag is an order to kubectl to not wait for a confirmation that the pods are deleted. It just sends request to delete and exits without waiting. This library can send the same requests and waiting is not implemented at all. In other words, this lib always acts like kubect with --force flag.

Do you have different experiences with deleting pods using the library?

tomplus avatar Jul 01 '18 22:07 tomplus

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot avatar Apr 24 '19 10:04 fejta-bot

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten

fejta-bot avatar May 24 '19 11:05 fejta-bot

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close

fejta-bot avatar Jun 23 '19 12:06 fejta-bot

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close

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.

k8s-ci-robot avatar Jun 23 '19 12:06 k8s-ci-robot

Not sure if things were different in 2019, but just for clarification since this still ranks pretty high on Google:

--grace-period=0 alone in kubectl (without --force) is equivalent to --grace-period=1 since kubectl has some "backwards compability" to avoid actually instant terminating in case --force is missing. https://github.com/kubernetes/kubectl/blob/826006cdb947f80a679ff1eb3cb53f183a6a9bf2/pkg/cmd/delete/delete.go#L189-L196

All --force in kubectl does here is not waiting and actually setting the grace period to 0.

So converting kubectl <-> Python API means: --grace-period=0 = grace_period_seconds=1 --grace-period=0 --force = grace_period_seconds=0

Nirusu avatar Aug 28 '23 14:08 Nirusu

+1 I'd like to be able to force delete pods using the python library.

We have pods stuck in terminating that I'd like to delete.

MalteMagnussen avatar Nov 09 '23 10:11 MalteMagnussen

@MalteMagnussen Setting grace_period_seconds=0 in delete(_namespaced)_pod should do the same thing.

Nirusu avatar Nov 09 '23 12:11 Nirusu