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

Open
pietervogelaar opened this Issue Feb 10, 2017 · 3 comments

Projects

None yet

3 participants

@pietervogelaar
---
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
Member
Kami commented Feb 15, 2017

/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

Any update on this?

@lakshmi-kannan
Contributor

@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.

@lakshmi-kannan lakshmi-kannan added this to the 2.2.1 milestone Feb 17, 2017
@lakshmi-kannan lakshmi-kannan added the bug label Feb 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment