Hi,

This is an additional email to continue discussion about new Mistral DSL 
capabilities. This time about conditional transitions and task dependencies. 
Here’s the link to the corresponding etherpad: 
https://etherpad.openstack.org/p/mistral-poc.

For convenience, I’m providing the snippet about conditional transitions right 
in this message.

"
Conditional Transitions

Option #1 ('requires' with condition)
In this case we add additional optional condition in dependencies declaration.

    task1 # task1 doesn't have dependencies
      action: MyRest:action1

    task2:
      requires: task1              # task2 is allowed to run if task1 has 
finished with success
      action: MyRest:action2

      task3:
        requires:                         # task3 is allowed to run if task1 
and task2 have finished and corresponding conditions are true
            task1: $.value1 = 34
            task2: $.value2 = 245
        
        action: MyRest:action3

    task4:
        requires: [task2, task3]      # task4 is allowed to run if task2 and 
task3 has finished with success
        action: MyRest:action4

Option #2 (direct transition)
In this case after task completion we decided what to do next depending on task 
result.

    task1:
      action: MyRest:action1
      SUCCESS:
  - task2       # If task1 has finished with success then start task2
  - task3: $.value1 == 123      # If after completion of task1 variable 
"value1" in the context equals to "123" then start task3
 ERROR:
        - task10       # If task1 has finished with error then start task10

Option #3 (hybrid of 'requires' and direct transitions)
In this case we can specify both "requires" and direct transitions. In the 
example below task3 starts only when task1 and task2 have finished. Therefore 
task2 is an implicit dependency of task3 since task1 initiated execution of 
task2. It means that a task can start only if the entire sub-workflow initiated 
by "requires" clause has finished.

    task1:
      action: MyRest:action1
      SUCCESS
        - task2

    task2:
        action: MyRest:action2

    task3:
      action: MyRest:action3
      requires: 
        task1: $.value1 = 34
      SUCCESS:
        task4: '$.value1 == 123'
"

Note that we’re now considering 3 options to proceed with and our current 
preference is option #3 (mix of ‘requires’ and direct transitions) since it 
would give a lot of flexibility for designing real life workflows. In some 
cases it would be more convenient to describe a business process using task 
dependencies and in other cases use direct conditional transitions if 
“straightforward” flow definition is preferred.

Regardless of the option described here a user would start new workflow 
execution with specifying a particular task in a graph.

As always, we would like to get your feedback on this.

Thanks!

Renat Akhmerov
@ Mirantis Inc.



_______________________________________________
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

Reply via email to