StackStorm / st2

StackStorm (aka "IFTTT for Ops") is event-driven automation for auto-remediation, incident responses, troubleshooting, deployments, and more for DevOps and SREs. Includes rules engine, workflow, 160 integration packs with 6000+ actions (see https://exchange.stackstorm.org) and ChatOps. Installer at https://docs.stackstorm.com/install/index.html
https://stackstorm.com/
Apache License 2.0
6.07k stars 749 forks source link

Passing an array as parameter does not seem to work #3210

Open pietervogelaar opened 7 years ago

pietervogelaar commented 7 years ago
---
version: "2.0"

my_application.deploy:
  description: "Workflow to deploy an application"
  type: direct
  input:
    - repo_url
    - server_application
    - server_role
    - server_environment
  output:
    stdout: <% $.stdout %>
  tasks:
    get_hosts:
      action: my_core.get_hosts
      input:
        application: <% $.server_application %>
        role: <% $.server_role %>
        environment: <% $.server_environment %>
      publish:
        hosts: <% task(get_hosts).result.result %>
    update:
      action: my_application.update
      input:
        repo_url: <% $.repo_url %>
        hosts: <% $.hosts %>
      publish:
        stdout: <% task(update).result.stdout %>
        stderr: <% task(update).result.stderr %>

But I get the following error:

{
  "tasks": [
    {
      "state_info": null,
      "name": "get_hosts",
      "created_at": "2017-02-10 12:25:16.857967",
      "updated_at": "2017-02-10 12:25:18.358841",
      "id": "61c7d3f2-3c2a-446a-b431-dd92810fc75a",
      "workflow_execution_id": "ff091ab0-d693-4119-ade2-1d5d344d6439",
      "state": "SUCCESS",
      "result": {
        "stdout": "",
        "exit_code": 0,
        "stderr": "",
        "result": [
          "orchestration-orchestrator-01p.adinfra.example.com"
        ]
      },
      "published": {
        "hosts": [
          "orchestration-orchestrator-01p.adinfra.example.com"
        ]
      },
      "input": null,
      "workflow_name": "my_application.deploy"
    },
    {
      "state_info": "Can not evaluate YAQL expression:  $.hosts , data = {u'server_application': u'orchestration', u'repo_url': u...",
      "name": "update",
      "created_at": "2017-02-10 12:25:16.871725",
      "updated_at": "2017-02-10 12:25:16.877147",
      "id": "b23600e9-a23b-494d-92dd-4d4d214d6d43",
      "workflow_execution_id": "ff091ab0-d693-4119-ade2-1d5d344d6439",
      "state": "ERROR",
      "result": [],
      "published": {},
      "input": null,
      "workflow_name": "my_application.deploy"
    }
  ],
  "extra": {
    "state_info": "Failed to start task [task_ex=TaskExecution {'state_info': \"Can not evaluate YAQL expression:  $.hosts , data = {u'server_application': u'orchestration', u'repo_url': u's...",
    "state": "ERROR"
  }
}

Everything works fine if I hard code the hosts in the workflow:

update:
     action: my_application.update
     input:
       repo_url: <% $.repo_url %>
       hosts: ['somehost.example', 'anotherhost.example']

The hosts parameter of the update action is of type "array". But why doesn’t it work when I use the variable <% $.hosts %> ?

Kami commented 7 years ago

/cc @m4dcoder when you have a chance to look at it...

I think the issue is related to publish parameter being a string and not a list so you need a way to cast it to a list.

pietervogelaar commented 7 years ago

Any update on this?

lakshmi-kannan commented 7 years ago

@pietervogelaar We are currently busy with a release. So this item will be picked up only in the next release. Feel free to open a PR if you want to help.

jschoewe commented 1 year ago

Seeing as this references a deprecated mistral workflow and publishing and passing arrays works fine in orquesta, I'd say this bug can be closed