Skip to content

Commit

Permalink
fix(reana-admin): skip retention rules for deleted workspaces (#697)
Browse files Browse the repository at this point in the history
Closes #693
  • Loading branch information
mdonadoni committed Aug 29, 2024
1 parent 3596ee0 commit d1cd1a5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions reana_server/reana_admin/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import datetime
import logging
from pathlib import Path
import secrets
import sys
import traceback
Expand Down Expand Up @@ -850,6 +851,17 @@ def retention_rules_apply(
click.echo("No rules to be applied!")

for rule in pending_rules:
if not Path(rule.workflow.workspace_path).exists():
# workspace was deleted, set rule as if it was already applied
click.secho(
f"Workspace {rule.workflow.workspace_path} of rule {rule.id_} does not exist, "
"setting the status to `applied`",
fg="red",
)
update_workspace_retention_rules(
[rule], WorkspaceRetentionRuleStatus.applied
)
continue
# if there are errors, the status of the rule will be reset to `active`
# so that the rule will be applied again at the next execution of the cronjob
next_status = WorkspaceRetentionRuleStatus.active
Expand Down

0 comments on commit d1cd1a5

Please sign in to comment.