Skip to content
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

reana-admin: add retention-rules-apply command #525

Merged
merged 1 commit into from
Jul 26, 2022

Conversation

mdonadoni
Copy link
Member

@mdonadoni mdonadoni commented Jul 19, 2022

Add command to apply pending retention rules, deleting the necessary files or directories.

How to test:

  1. Modify one of the demo examples, defining some retention rules
  2. Fake a different current time (e.g. one day in the future)
--- a/reana_server/reana_admin/cli.py
+++ b/reana_server/reana_admin/cli.py
@@ -748,6 +748,7 @@ def check_workflows(
 def retention_rules_apply() -> None:
     """Apply pending retentions rules."""
     current_time = datetime.datetime.now()
+    current_time = current_time + datetime.timedelta(days=1)
     pending_rules = WorkspaceRetentionRule.query.filter(
         WorkspaceRetentionRule.status == WorkspaceRetentionRuleStatus.active,
         WorkspaceRetentionRule.apply_on < current_time,
  1. Run the retention-rules-apply command
kubectl exec -it deployments/reana-server -- flask reana-admin retention-rules-apply

Expected result: The retention rules are applied correctly and the correct files are deleted.

@mdonadoni mdonadoni added this to In review in Workspace-Retention Jul 19, 2022
@codecov-commenter
Copy link

Codecov Report

Merging #525 (3e3acdb) into master (1ac23c4) will increase coverage by 0.70%.
The diff coverage is 90.56%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #525      +/-   ##
==========================================
+ Coverage   52.62%   53.32%   +0.70%     
==========================================
  Files          29       30       +1     
  Lines        2805     2858      +53     
==========================================
+ Hits         1476     1524      +48     
- Misses       1329     1334       +5     
Impacted Files Coverage Δ
reana_server/reana_admin/retention_rule_deleter.py 90.47% <90.47%> (ø)
reana_server/reana_admin/cli.py 48.52% <90.90%> (+1.41%) ⬆️

Copy link

@VMois VMois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice job!

One small thing to do is to add a line to CHANGES.

Add command to apply pending retention rules, deleting the necessary
files or directories.
Copy link

@VMois VMois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job!

@mdonadoni mdonadoni merged commit 5d9e199 into reanahub:master Jul 26, 2022
@mdonadoni mdonadoni moved this from In review to Done in Workspace-Retention Jul 26, 2022
@mdonadoni mdonadoni deleted the retention-rules-daemon branch October 13, 2022 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants