diff --git a/CHANGES.rst b/CHANGES.rst index 2d376980..a8dcaab2 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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) --------------------------- diff --git a/reana_workflow_controller/rest/workflows_status.py b/reana_workflow_controller/rest/workflows_status.py index b8acd5e5..37f41832 100644 --- a/reana_workflow_controller/rest/workflows_status.py +++ b/reana_workflow_controller/rest/workflows_status.py @@ -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) diff --git a/tests/test_views.py b/tests/test_views.py index b7d841d5..98119954 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -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, @@ -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)