Skip to content

Commit

Permalink
rest: return error if workflow is deleted without workspace
Browse files Browse the repository at this point in the history
- if "workspace" parameter is not specified, delete workspace by default.

closes #460
  • Loading branch information
Vladyslav Moisieienkov committed Jul 14, 2022
1 parent 1993a85 commit b19d0d9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Version 0.9.0 (UNRELEASED)
- Changes the workflow status endpoint to update the disk quota usage when a workspace is deleted.
- Changes the CWD of jupyter's terminals to the directory of the workflow's workspace.
- Changes the k8s specification of interactive sessions' pods to remove the environment variables used for service discovery.
- Changes the workflow set status endpoint to remove the workspace by default when a workflow is deleted and to fail if the request is asking not to delete the workspace.

Version 0.8.1 (2022-02-07)
---------------------------
Expand Down
11 changes: 10 additions & 1 deletion reana_workflow_controller/rest/workflows_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,16 @@ def set_workflow_status(workflow_id_or_name): # noqa
)
elif status == DELETED:
all_runs = True if request.json.get("all_runs") else False
workspace = True if request.json.get("workspace") else False
workspace = True if request.json.get("workspace", True) else False
if not workspace:
return (
jsonify(
{
"message": "Workspace must always be deleted when deleting a workflow.",
}
),
400,
)
return delete_workflow(workflow, all_runs, workspace)
if status == STOP:
stop_workflow(workflow)
Expand Down
5 changes: 4 additions & 1 deletion tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,9 @@ def test_delete_all_workflow_runs(
assert workflow.status == RunStatus.deleted


@pytest.mark.parametrize("workspace", [True, False])
@pytest.mark.parametrize(
"workspace", [True, pytest.param(False, marks=pytest.mark.xfail(strict=True))]
)
def test_workspace_deletion(
app,
session,
Expand Down Expand Up @@ -1231,6 +1233,7 @@ def test_workspace_deletion(
content_type="application/json",
data=json.dumps({"workspace": workspace}),
)
assert res.status_code == 200
if workspace:
assert not os.path.exists(workflow.workspace_path)

Expand Down

0 comments on commit b19d0d9

Please sign in to comment.