python: Deleting job with delete_namespaced_job() does not delete pods
When deleting a job with BatchV1Api.delete_namespaced_job, the job resource is deleted, but the pod(s) remain.
From this documentation, my assumption was to try Ophaned, Background, or Foreground as the propagation_policy, but none of them did anything to the pod after the job was deleted.
Upon further inspection of the pod metadata, both finalizers and owner_references are set with None.
Here’s the gist of the script I used to reproduce this.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (4 by maintainers)
Commits related to this issue
- Merge pull request #234 from yliaog/master quick fix of decoding error for BOOKMARK event — committed to yliaog/client-python by k8s-ci-robot 3 years ago
@alanbchristie
See #423
The following code works for me:
body = client.V1DeleteOptions(propagation_policy='Background')resp = api.delete_namespaced_deployment(name=item.metadata.name, body=body, namespace=self.namespace)I disagree - I just tested the parameter like this
and it works as expected. Now I don’t know if it will be deprecated but saying that it has no effect is incorrect.
Thanks all, I met the same problem and got solved by your solutions. By the way, since
propagation_policyparameter has no effect by passing the parameter as query parameter, could @thomaswtsang update doc and remind developers to put it in the body?Sorry, I know this topic is closed but I’m running into this problem now and this and #43329 don’t really help. Can you explain precisely how you fixed this i.e. what do you mean by Try encoding the parameter in the body (set it in V1DeleteOptions).?
Do I need to set anything in the
V1DeleteOptions()body object and what, if any, other arguments need to be passed todelete_namespaced_job?