StackStorm / orquestaconvert

Converts Mistral workflows into Orchestra workflows
Apache License 2.0
13 stars 7 forks source link

When converting a mistral-v2 workflow, jinja conversion from mistral on-success -> orquesta when is problematic #25

Closed tim-ireland closed 5 years ago

tim-ireland commented 5 years ago

First off, thanks for this utility, it saved a bunch of time and effort with tedious yaml conversions!

I noticed for a subset of mistral workflows that the jinja expression from mistral on-success clause is resulting in access to an undefined variable when converted into an orquesta when clause.

Example:

A mistral workflow with the following structure, where the initial task calls an action, and the on-success clause ensures that the published variable (in this case operations dict) is not null (len = 0).

version: "2.0"

input:
  - uuid

tasks:  
   task_1:
     action: ‘pack.action_1’
     # returns result as dict.
     input:
          foreign_id: <% $.uuid %>
      publish:
          operations: <% task(task_1).result.result[‘operations’] %>
          namespace: <% task(task_1).result.result['namespace'] %>
        on-success:
          - task_2: <% len($.operations) != 0 %>
    ...

Using the workflow conversion, this is translated to the following form. This is problematic because in orquesta, the when clause seems to occur before the publish has made the variables available to the context. Specifically, ctx().operations is accessed in the when clause, before it's defined.

---
version: '1.0'
input:
  - uuid
  task_1:
    action: pack.action_1
    input:
      foreign_id: <% ctx().uuid %>
    next:
      - when: <% succeeded() and (len(ctx().operations) != 0) %>
        publish:
          - operations: <% result().result['operations'] %>
          - namespace: <% result().result['namespace'] %>
        do:
          - task_2
...

Also, another minor thing is that our mistral workflows had name and description at the top, which I had to comment out for the conversion utility to accept them.

Again, thanks!

nmaludy commented 5 years ago

@tim-ireland this has been merged in, give it a shot please!