Browse Source

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>
tags/8.0.0.0rc1^0
Oleg Ovcharuk 2 months ago
parent
commit
99ebc1b5f7
2 changed files with 57 additions and 0 deletions
  1. 14
    0
      mistral/engine/policies.py
  2. 43
    0
      mistral/tests/unit/engine/test_policies.py

+ 14
- 0
mistral/engine/policies.py View File

@@ -160,6 +160,15 @@ def _ensure_context_has_key(runtime_context, key):
160 160
     return runtime_context
161 161
 
162 162
 
163
+def _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
+
163 172
 class WaitBeforePolicy(base.TaskPolicy):
164 173
     _schema = {
165 174
         "properties": {
@@ -381,6 +390,11 @@ class RetryPolicy(base.TaskPolicy):
381 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 398
         break_triggered = (
385 399
             task_ex.state == states.ERROR and
386 400
             break_on_evaluation

+ 43
- 0
mistral/tests/unit/engine/test_policies.py View File

@@ -1227,6 +1227,49 @@ class PoliciesTest(base.EngineTestCase):
1227 1227
 
1228 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 1273
     @mock.patch.object(
1231 1274
         std_actions.EchoAction,
1232 1275
         'run',

Loading…
Cancel
Save