question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deleting job with delete_namespaced_job() does not delete pods

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

15reactions
drdivanocommented, Jan 16, 2018

@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)

1reaction
iomarcovalentecommented, Apr 15, 2021

thank you for all the discussion.

I had the same problem and confirmed that it is resolved by setting

        body = client.V1DeleteOptions(propagation_policy='Background')

agree that we shall remove the propagation_policy parameter in delete_namespaced_job() as it has no effect and cause confusion.

I disagree - I just tested the parameter like this

    api_response = api_instance.delete_namespaced_job(name, namespace, propagation_policy="Background")

and it works as expected. Now I don’t know if it will be deprecated but saying that it has no effect is incorrect.

Read more comments on GitHub >

github_iconTop Results From Across the Web

deleteNamespacedJob() do not delete pod · Issue #777 - GitHub
I use deleteNamespacedJob() to delete the job, but it throw a error issuse86.I catch the error but find the pod is still exist....
Read more >
How can I delete all pods via delete job - Stack Overflow
For Cronjob. You can use the successfulJobsHistoryLimit to manage the pod count, if you will set it to 0, POD will get removed...
Read more >
Creating, Updating and Deleting Resources with the Java ...
Here, we're just using the deleteNamespacedJob method to remove the job using default options for this specific kind of resource. If required, ...
Read more >
Deleting jobs using REST API does not delete the associated ...
I creating and deleting jobs by making REST API calls from inside a pod. But while deleting the job the associated pod is...
Read more >
Kubernetes Tasks - Prefect Docs
After the job is successfully completed, all resources by default are deleted: job and the corresponding pods. If job is in the failed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found