Skip to content

feat: allow to omit job cleanup with --kubernetes-omit-job-cleanup (for debugging) #55

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions snakemake_executor_plugin_kubernetes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ class ExecutorSettings(ExecutorSettingsBase):
"nargs": "+",
},
)
omit_job_cleanup: bool = field(
default=False,
metadata={
"help": "Do not delete jobs after they have finished or failed. "
"This is useful for debugging, or if your k8s cluster performs "
"automatic cleanups."
},
)


# Required:
Expand Down Expand Up @@ -502,7 +510,10 @@ def read_log(
self.logger.error(f"Job {j.external_jobid} failed.{msg}")
self.report_job_error(j, msg=msg, aux_logs=aux_logs)

if pod_name is not None:
if (
pod_name is not None
and not self.workflow.executor_settings.omit_job_cleanup
):
self._kubernetes_retry(
lambda j=j: self.safe_delete_job(
j.external_jobid, ignore_not_found=True
Expand All @@ -515,11 +526,12 @@ def read_log(
self.logger.info(f"Job {j.external_jobid} succeeded.")
self.report_job_success(j)

self._kubernetes_retry(
lambda j=j: self.safe_delete_job(
j.external_jobid, ignore_not_found=True
if not self.workflow.executor_settings.omit_job_cleanup:
self._kubernetes_retry(
lambda j=j: self.safe_delete_job(
j.external_jobid, ignore_not_found=True
)
)
)
else:
# still active
self.logger.debug(f"Job {j.external_jobid} is still active.")
Expand Down
Loading