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

fix(delete_workflow): set retention rules as inactive (#595) #595

Merged

Conversation

mdonadoni
Copy link
Member

Copy link

codecov bot commented Aug 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.13%. Comparing base (5ac27ef) to head (680e288).
Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #595      +/-   ##
==========================================
+ Coverage   75.11%   75.13%   +0.01%     
==========================================
  Files          15       15              
  Lines        1475     1476       +1     
==========================================
+ Hits         1108     1109       +1     
  Misses        367      367              
Files with missing lines Coverage Δ
reana_workflow_controller/rest/utils.py 81.12% <100.00%> (+0.05%) ⬆️

mdonadoni added a commit to mdonadoni/reana-workflow-controller that referenced this pull request Aug 9, 2024
@mdonadoni mdonadoni force-pushed the retention-rules-deleted-workflow branch from 88e40fe to 8422040 Compare August 9, 2024 10:32
mdonadoni added a commit to mdonadoni/reana-workflow-controller that referenced this pull request Aug 26, 2024
@mdonadoni mdonadoni force-pushed the retention-rules-deleted-workflow branch from 8422040 to bc614b8 Compare August 26, 2024 13:43
int_session = workflow.sessions.first()
if int_session:
kwrm = KubernetesWorkflowRunManager(workflow)
kwrm.stop_interactive_session(int_session.id_)

if workspace:
# 2. disable retention rules, as the workspace will be deleted
workflow.inactivate_workspace_retention_rules()
# 3. delete the workspace
Copy link
Member

Choose a reason for hiding this comment

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

Minor comment: wouldn't it be better to change the order of 2 and 3 so that the actual deletion of files will occur first? Thinking about a possible corner case what if something goes wrong with the retention rule inactivation: at least the files would be deleted by the time we get an exception from that function if we switch the order. (Assuming that the most frequent use case is for the researcher to liberate some disk space.)

@mdonadoni mdonadoni force-pushed the retention-rules-deleted-workflow branch from bc614b8 to 680e288 Compare August 29, 2024 08:32
Copy link
Member

@tiborsimko tiborsimko left a comment

Choose a reason for hiding this comment

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

Works well 👍

$ grep -C 1 retention reana.yaml
workspace:
  retention_days:
    '*.root': 10
$ reana-client run -w test
$ sleep 60
$ reana-client status -w test | grep -cw finished
1
$ reana-client delete -w test
$ kubectl create job --from cronjob/reana-retention-rules-apply reana-retention-rules-apply2
job.batch/reana-retention-rules-apply2 created
$ kubectl logs reana-retention-rules-apply2-p5d9n
Setting the status of all the rules that will be applied to `pending`
Fetching all the pending rules
No rules to be applied!

@tiborsimko tiborsimko merged commit 680e288 into reanahub:master Aug 29, 2024
14 checks passed
@mdonadoni mdonadoni deleted the retention-rules-deleted-workflow branch August 29, 2024 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

retention_rules: error when applying rule to deleted workflow
2 participants