Skip to content

Commit

Permalink
fix(reana-admin): skip retention rules with deleted workspace (#697)
Browse files Browse the repository at this point in the history
Closes #693
  • Loading branch information
mdonadoni committed Aug 9, 2024
1 parent 703af19 commit 1d776f3
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(

Check warning on line 856 in reana_server/reana_admin/cli.py

View check run for this annotation

Codecov / codecov/patch

reana_server/reana_admin/cli.py#L856

Added line #L856 was not covered by tests
f"Workspace {rule.workflow.workspace_path} of rule {rule.id_} does not exist, "
"setting the status to `applied`",
fg="red",
)
update_workspace_retention_rules(

Check warning on line 861 in reana_server/reana_admin/cli.py

View check run for this annotation

Codecov / codecov/patch

reana_server/reana_admin/cli.py#L861

Added line #L861 was not covered by tests
[rule], WorkspaceRetentionRuleStatus.applied
)
continue

Check warning on line 864 in reana_server/reana_admin/cli.py

View check run for this annotation

Codecov / codecov/patch

reana_server/reana_admin/cli.py#L864

Added line #L864 was not covered by tests
# 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 1d776f3

Please sign in to comment.