Skip to content

Commit

Permalink
fix(delete_workflow): set retention rules as inactive (reanahub#595)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonadoni committed Aug 29, 2024
1 parent 5ac27ef commit 680e288
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion reana_workflow_controller/rest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,16 @@ def delete_workflow(workflow, all_runs=False, workspace=False):
.all()
)
for workflow in to_be_deleted:
# 1. Stop open interactive sessions
int_session = workflow.sessions.first()
if int_session:
kwrm = KubernetesWorkflowRunManager(workflow)
kwrm.stop_interactive_session(int_session.id_)

if workspace:
# 2. delete the workspace
remove_workflow_workspace(workflow.workspace_path)

# 3. update the disk usage of the user
disk_resource = get_default_quota_resource(ResourceType.disk.name)
workflow_disk_resource = WorkflowResource.query.filter(
WorkflowResource.workflow_id == workflow.id_,
Expand All @@ -265,6 +267,11 @@ def delete_workflow(workflow, all_runs=False, workspace=False):
bytes_to_sum=-disk_usage,
override_policy_checks=True,
)

# 4. disable retention rules, as the workspace was deleted
workflow.inactivate_workspace_retention_rules()

# 5. set the workflow as deleted in the database
_mark_workflow_as_deleted_in_db(workflow)
remove_workflow_jobs_from_cache(workflow)

Expand Down

0 comments on commit 680e288

Please sign in to comment.