From 146d1c17e24f936f8bc365c69bf9f72a084e62ae Mon Sep 17 00:00:00 2001 From: Pierre Gaxatte Date: Mon, 4 Jun 2018 17:28:57 +0200 Subject: [PATCH] Fix force parameter being always added to URL in execution delete Co-Authored-By: Dougal Matthews Closes-Bug: 1775027 Change-Id: Ia3984a7879ed93292e39b03af65253fb8c4f67e8 --- mistralclient/api/v2/executions.py | 3 ++- mistralclient/tests/functional/cli/v2/base_v2.py | 2 +- mistralclient/tests/functional/cli/v2/cli_tests_v2.py | 6 ++++-- ...sion-with-execution-force-delete-af8d1968cb2673ef.yaml | 8 ++++++++ 4 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/fix-regression-with-execution-force-delete-af8d1968cb2673ef.yaml diff --git a/mistralclient/api/v2/executions.py b/mistralclient/api/v2/executions.py index e95c3789..7db0aec6 100644 --- a/mistralclient/api/v2/executions.py +++ b/mistralclient/api/v2/executions.py @@ -117,7 +117,8 @@ class ExecutionManager(base.ResourceManager): self._ensure_not_empty(id=id) qparams = {} - qparams['force'] = bool(force) + if force: + qparams['force'] = True query_string = ("?%s" % urlparse.urlencode(list(qparams.items())) if qparams else "") diff --git a/mistralclient/tests/functional/cli/v2/base_v2.py b/mistralclient/tests/functional/cli/v2/base_v2.py index 4f0d69ca..f76679c3 100644 --- a/mistralclient/tests/functional/cli/v2/base_v2.py +++ b/mistralclient/tests/functional/cli/v2/base_v2.py @@ -245,7 +245,7 @@ class MistralClientTestBase(base.MistralCLIAuth, base.MistralCLIAltAuth): self.mistral_cli, admin, 'execution-delete', - params=exec_id + params="{} --force".format(exec_id) ) return ex diff --git a/mistralclient/tests/functional/cli/v2/cli_tests_v2.py b/mistralclient/tests/functional/cli/v2/cli_tests_v2.py index 2b7c8cca..befe02cc 100644 --- a/mistralclient/tests/functional/cli/v2/cli_tests_v2.py +++ b/mistralclient/tests/functional/cli/v2/cli_tests_v2.py @@ -660,7 +660,8 @@ class ExecutionCLITests(base_v2.MistralClientTestBase): self.assertIn(wf_name, [ex['Workflow name'] for ex in execs]) self.assertIn(namespace, [ex['Workflow namespace'] for ex in execs]) - self.mistral_admin('execution-delete', params=exec_id) + params = "{} --force".format(exec_id) + self.mistral_admin('execution-delete', params=params) def test_execution_create_delete(self): @@ -688,7 +689,8 @@ class ExecutionCLITests(base_v2.MistralClientTestBase): self.assertIn(exec_id, [ex['ID'] for ex in execs]) self.assertIn(wf_name, [ex['Workflow name'] for ex in execs]) - self.mistral_admin('execution-delete', params=exec_id) + params = "{} --force".format(exec_id) + self.mistral_admin('execution-delete', params=params) def test_execution_create_with_input_and_start_task(self): execution = self.execution_create( diff --git a/releasenotes/notes/fix-regression-with-execution-force-delete-af8d1968cb2673ef.yaml b/releasenotes/notes/fix-regression-with-execution-force-delete-af8d1968cb2673ef.yaml new file mode 100644 index 00000000..4dca33b5 --- /dev/null +++ b/releasenotes/notes/fix-regression-with-execution-force-delete-af8d1968cb2673ef.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + mistralclient 3.5.0 introduced a new --force option to delete executions + that are still running. However, this had the unintended impact of passing + force=false when it wasn't provided. This is incompatible with previous + releases of the Mistral API which reject requests as they don't recognise + "force".