summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Ovcharuk <vgvoleg@gmail.com>2019-03-11 15:07:57 +0300
committerOleg Ovcharuk <vgvoleg@gmail.com>2019-03-11 22:29:08 +0300
commit99ebc1b5f73f2a3ffc3a44e2ebe1119cfb033719 (patch)
tree78a6e1191acd2d3b1a022aac099a53becb295d8b
parent608367f28d10decb0e22a8fe7a58b5c38782a1e9 (diff)
Retries shouldn't execute if join task failed because of child task
Change-Id: Ideaa9938497f74335af633044cb6e98fbb1522d8 Closes-Bug: #1819418 Signed-off-by: Oleg Ovcharuk <vgvoleg@gmail.com>
Notes
Notes (review): Code-Review+2: Andras Kovi <akovi@nokia.com> Code-Review+1: dharmendra kushwaha <dharmendra.kushwaha@india.nec.com> Code-Review+2: Renat Akhmerov <renat.akhmerov@gmail.com> Workflow+1: Renat Akhmerov <renat.akhmerov@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 12 Mar 2019 15:44:29 +0000 Reviewed-on: https://review.openstack.org/642431 Project: openstack/mistral Branch: refs/heads/master
-rw-r--r--mistral/engine/policies.py14
-rw-r--r--mistral/tests/unit/engine/test_policies.py43
2 files changed, 57 insertions, 0 deletions
diff --git a/mistral/engine/policies.py b/mistral/engine/policies.py
index b3e5ea3..eb281b3 100644
--- a/mistral/engine/policies.py
+++ b/mistral/engine/policies.py
@@ -160,6 +160,15 @@ def _ensure_context_has_key(runtime_context, key):
160 return runtime_context 160 return runtime_context
161 161
162 162
163def _has_incomplete_inbound_tasks(task_ex):
164 if "triggered_by" not in task_ex.runtime_context:
165 return False
166 for trigger in task_ex.runtime_context["triggered_by"]:
167 if trigger["event"] == "not triggered":
168 return True
169 return False
170
171
163class WaitBeforePolicy(base.TaskPolicy): 172class WaitBeforePolicy(base.TaskPolicy):
164 _schema = { 173 _schema = {
165 "properties": { 174 "properties": {
@@ -381,6 +390,11 @@ class RetryPolicy(base.TaskPolicy):
381 (self._continue_on_clause and not continue_on_evaluation) 390 (self._continue_on_clause and not continue_on_evaluation)
382 ) 391 )
383 392
393 stop_continue_flag = (
394 stop_continue_flag or
395 _has_incomplete_inbound_tasks(task_ex)
396 )
397
384 break_triggered = ( 398 break_triggered = (
385 task_ex.state == states.ERROR and 399 task_ex.state == states.ERROR and
386 break_on_evaluation 400 break_on_evaluation
diff --git a/mistral/tests/unit/engine/test_policies.py b/mistral/tests/unit/engine/test_policies.py
index d96279a..240796b 100644
--- a/mistral/tests/unit/engine/test_policies.py
+++ b/mistral/tests/unit/engine/test_policies.py
@@ -1227,6 +1227,49 @@ class PoliciesTest(base.EngineTestCase):
1227 1227
1228 self.assertDictEqual({'result': 'mocked result'}, wf_output) 1228 self.assertDictEqual({'result': 'mocked result'}, wf_output)
1229 1229
1230 def test_retry_failed_join_task(self):
1231 retry_wb = """---
1232 version: '2.0'
1233
1234 name: wb
1235
1236 workflows:
1237 wf1:
1238 task-defaults:
1239 retry:
1240 count: 1
1241 delay: 0
1242 tasks:
1243 task1:
1244 action: std.noop
1245 on-success: join_task
1246 task2:
1247 action: std.fail
1248 on-success: join_task
1249 join_task:
1250 action: std.noop
1251 join: all
1252 """
1253 wb_service.create_workbook_v2(retry_wb)
1254
1255 # Start workflow.
1256 wf_ex = self.engine.start_workflow('wb.wf1')
1257
1258 self.await_workflow_error(wf_ex.id)
1259
1260 with db_api.transaction():
1261 # Note: We need to reread execution to access related tasks.
1262 wf_ex = db_api.get_workflow_execution(wf_ex.id)
1263
1264 tasks = wf_ex.task_executions
1265
1266 self._assert_single_item(
1267 tasks, name="task2", state=states.ERROR
1268 )
1269 self._assert_single_item(
1270 tasks, name="join_task", state=states.ERROR
1271 )
1272
1230 @mock.patch.object( 1273 @mock.patch.object(
1231 std_actions.EchoAction, 1274 std_actions.EchoAction,
1232 'run', 1275 'run',