{"action":"created","issue":{"url":"https://api.github.com/repos/StackStorm/st2/issues/4740","repository_url":"https://api.github.com/repos/StackStorm/st2","labels_url":"https://api.github.com/repos/StackStorm/st2/issues/4740/labels{/name}","comments_url":"https://api.github.com/repos/StackStorm/st2/issues/4740/comments","events_url":"https://api.github.com/repos/StackStorm/st2/issues/4740/events","html_url":"https://github.com/StackStorm/st2/issues/4740","id":467458254,"node_id":"MDU6SXNzdWU0Njc0NTgyNTQ=","number":4740,"title":"Orquesta workflows have incorrect status","user":{"login":"bishopbm1","id":15911425,"node_id":"MDQ6VXNlcjE1OTExNDI1","avatar_url":"https://avatars2.githubusercontent.com/u/15911425?v=4","gravatar_id":"","url":"https://api.github.com/users/bishopbm1","html_url":"https://github.com/bishopbm1","followers_url":"https://api.github.com/users/bishopbm1/followers","following_url":"https://api.github.com/users/bishopbm1/following{/other_user}","gists_url":"https://api.github.com/users/bishopbm1/gists{/gist_id}","starred_url":"https://api.github.com/users/bishopbm1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bishopbm1/subscriptions","organizations_url":"https://api.github.com/users/bishopbm1/orgs","repos_url":"https://api.github.com/users/bishopbm1/repos","events_url":"https://api.github.com/users/bishopbm1/events{/privacy}","received_events_url":"https://api.github.com/users/bishopbm1/received_events","type":"User","site_admin":false},"labels":[{"id":94405702,"node_id":"MDU6TGFiZWw5NDQwNTcwMg==","url":"https://api.github.com/repos/StackStorm/st2/labels/bug","name":"bug","color":"fc2929","default":true},{"id":950741519,"node_id":"MDU6TGFiZWw5NTA3NDE1MTk=","url":"https://api.github.com/repos/StackStorm/st2/labels/workflows:%20orquesta","name":"workflows: orquesta","color":"8647ad","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2019-07-12T14:55:41Z","updated_at":"2019-07-16T22:53:07Z","closed_at":null,"author_association":"NONE","body":"## SUMMARY\r\n\r\nWhen using orquesta workflows if a task fails but still publishes content the workflow is marked as succeeded. This happens if there is no when clause and when there is a when failed clause.\r\n\r\n### STACKSTORM VERSION\r\n\r\n```\r\n# st2 --version\r\nst2 3.1.0, on Python 2.7.5\r\n```\r\n\r\n##### OS, environment, install method\r\n\r\n```\r\n# cat /etc/os-release\r\nNAME=\"Red Hat Enterprise Linux Server\"\r\nVERSION=\"7.6 (Maipo)\"\r\nID=\"rhel\"\r\n```\r\nInstall method is Puppet forge module\r\n\r\n## Steps to reproduce the problem\r\n\r\nUsing the examples.orquesta-basic workflow. We can need to modify the workflow to remove the `when: <% succeeded() %>` or modify it to be `when: <% succeeded() or failed() %>`\r\n\r\nWorkflow:\r\n```\r\nversion: 1.0\r\n\r\ndescription: A basic workflow that runs an arbitrary linux command.\r\n\r\ninput:\r\n  - cmd\r\n  - timeout\r\n\r\ntasks:\r\n  task1:\r\n    action: core.local cmd=<% ctx(cmd) %> timeout=<% ctx(timeout) %>\r\n    next:\r\n      - when: <% succeeded() or failed() %>\r\n        publish:\r\n          - stdout: <% result().stdout %>\r\n          - stderr: <% result().stderr %>\r\n\r\noutput:\r\n  - stdout: <% ctx(stdout) %>\r\n```\r\nor:\r\n```\r\nversion: 1.0\r\n\r\ndescription: A basic workflow that runs an arbitrary linux command.\r\n\r\ninput:\r\n  - cmd\r\n  - timeout\r\n\r\ntasks:\r\n  task1:\r\n    action: core.local cmd=<% ctx(cmd) %> timeout=<% ctx(timeout) %>\r\n    next:\r\n      - publish:\r\n          - stdout: <% result().stdout %>\r\n          - stderr: <% result().stderr %>\r\n\r\noutput:\r\n  - stdout: <% ctx(stdout) %>\r\n```\r\n\r\nAction file was unaltered:\r\n```\r\n---\r\nname: orquesta-basic\r\npack: examples\r\ndescription: Run a local linux command\r\nrunner_type: orquesta\r\nentry_point: workflows/orquesta-basic.yaml\r\nenabled: true\r\nparameters:\r\n  cmd:\r\n    required: true\r\n    type: string\r\n  timeout:\r\n    type: integer\r\n    default: 60\r\n```\r\n\r\ncan be forced to fail by running invalid command:\r\n```\r\nst2 run examples.orquesta-basic cmd=\"secho 'hi'\"\r\n```\r\n\r\n## Expected Results\r\nI would expect the results of the workflow to be failed when the task fails unless manually overridden.\r\n\r\n## Actual Results\r\n\r\nThe workflow says succeeded even though the single task failed. Looking at the logs it looks like a second subtask is formed for the publish method that succeeds and send that to the workflow.\r\n```\r\n# st2 run examples.orquesta-basic cmd=\"secho 'hi'\"\r\n..\r\nid: 5d289d9e49b3d2af833a29a9\r\naction.ref: examples.orquesta-basic\r\nparameters: \r\n  cmd: secho 'hi'\r\nstatus: succeeded\r\nstart_timestamp: Fri, 12 Jul 2019 14:47:58 UTC\r\nend_timestamp: Fri, 12 Jul 2019 14:48:02 UTC\r\nresult: \r\n  output:\r\n    stdout: ''\r\n+--------------------------+---------------------+-------+------------+-------------------------------+\r\n| id                       | status              | task  | action     | start_timestamp               |\r\n+--------------------------+---------------------+-------+------------+-------------------------------+\r\n| 5d289da049b3d2af5f26fa4f | failed (1s elapsed) | task1 | core.local | Fri, 12 Jul 2019 14:48:00 UTC |\r\n+--------------------------+---------------------+-------+------------+-------------------------------+\r\n```\r\nAdded debugging logs to:\r\nhttps://github.com/StackStorm/orquesta/blob/master/orquesta/conducting.py#L624\r\nand produced the following logs showing the second subtask.\r\n```\r\n2019-07-12 09:38:43,757 140001394854000 DEBUG conducting [-] Conductor Event Status: [failed]\r\n2019-07-12 09:38:43,757 140001394854000 DEBUG conducting [-] Conductor staged task: None\r\n2019-07-12 09:38:43,758 140001394854000 DEBUG conducting [-] Conductor task state entry: {u'status': u'running', u'route': 0, u'next': {}, u'ctxs': {u'in': [0]}, u'prev': {}, u'id': u'task1'}\r\n2019-07-12 09:38:43,758 140001394854000 DEBUG conducting [-] Conductor task state entry: {u'status': u'running', u'route': 0, u'next': {}, u'ctxs': {u'in': [0]}, u'prev': {}, u'id': u'task1'}\r\n2019-07-12 09:38:43,759 140001394854000 DEBUG conducting [-] Conductor task state idx: 0\r\n2019-07-12 09:38:43,759 140001394854000 DEBUG conducting [-] Conductor task state entry: {u'status': u'running', u'route': 0, u'next': {}, u'ctxs': {u'in': [0]}, u'prev': {}, u'id': u'task1'}\r\n2019-07-12 09:38:43,760 140001394854000 DEBUG conducting [-] Conductor task state idx: 0\r\n2019-07-12 09:38:43,761 140001394854000 DEBUG conducting [-] Conductor staged task: None\r\n2019-07-12 09:38:43,761 140001394854000 DEBUG conducting [-] Conductor old task status: running\r\n2019-07-12 09:38:43,762 140001394854000 DEBUG conducting [-] Conductor new task status: failed\r\n2019-07-12 09:38:43,770 140001394854000 DEBUG conducting [-] Conductor Event Status: [succeeded]\r\n2019-07-12 09:38:43,771 140001394854000 DEBUG conducting [-] Conductor staged task: {'ready': True, 'route': 0, 'ctxs': {'in': [0, 1]}, 'prev': {u'task1__t0': 0}, 'id': u'noop'}\r\n2019-07-12 09:38:43,771 140001394854000 DEBUG conducting [-] Conductor task state entry: None\r\n2019-07-12 09:38:43,772 140001394854000 DEBUG conducting [-] Conductor task state entry: {'ctxs': {'in': [0, 1]}, 'route': 0, 'prev': {u'task1__t0': 0}, 'id': u'noop', 'next': {}}\r\n2019-07-12 09:38:43,772 140001394854000 DEBUG conducting [-] Conductor task state idx: 1\r\n2019-07-12 09:38:43,773 140001394854000 DEBUG conducting [-] Conductor task state entry: {'ctxs': {'in': [0, 1]}, 'route': 0, 'prev': {u'task1__t0': 0}, 'id': u'noop', 'next': {}}\r\n2019-07-12 09:38:43,774 140001394854000 DEBUG conducting [-] Conductor task state idx: 1\r\n2019-07-12 09:38:43,774 140001394854000 DEBUG conducting [-] Conductor staged task: {'ready': True, 'route': 0, 'ctxs': {'in': [0, 1]}, 'prev': {u'task1__t0': 0}, 'id': u'noop'}\r\n2019-07-12 09:38:43,775 140001394854000 DEBUG conducting [-] Conductor old task status: null\r\n2019-07-12 09:38:43,775 140001394854000 DEBUG conducting [-] Conductor new task status: succeeded\r\n2019-07-12 09:38:43,793 140001394854000 DEBUG workflows [-] [5d288d6149b3d2af833a2991] Conductor: {'state': {'status': 'succeeded', 'tasks': {u'task1__r0': 0, u'noop__r0': 1}, 'sequence': [{u'status': 'failed', 'term': True, u'route': 0, u'next': {u'noop__t0': True}, u'ctxs': {u'in': [0], 'out': {u'noop__t0': 1}}, u'prev': {}, u'id': u'task1'}, {'status': 'succeeded', 'term': True, 'route': 0, 'next': {}, 'ctxs': {'in': [0, 1]}, 'prev': {u'task1__t0': 0}, 'id': u'noop'}], 'contexts': [{u'parent': {u'user': u'test', u'pack': u'examples'}, u'cmd': u\"secho 'hi'\", u'st2': {u'workflow_execution_id': u'5d288d6249b3d2ae94b89c73', u'pack': u'examples', u'action_execution_id': u'5d288d6149b3d2af833a2991', u'api_url': u'http://127.0.0.1:9101/v1', u'user': u'test'}, u'timeout': 60}, {u'stdout': {u'failed': True, u'stderr': u'bash: secho: command not found', u'return_code': 127, u'succeeded': False, u'stdout': u''}}], 'staged': [], 'routes': [[]]}, 'errors': [{'message': 'Execution failed. See result for details.', 'type': 'error', 'result': {u'succeeded': False, u'failed': True, u'return_code': 127, u'stderr': u'bash: secho: command not found', u'stdout': u''}, 'task_id': u'task1'}], 'log': [], 'context': {u'parent': {u'user': u'test', u'pack': u'examples'}, u'st2': {u'workflow_execution_id': u'5d288d6249b3d2ae94b89c73', u'user': u'test', u'action_execution_id': u'5d288d6149b3d2af833a2991', u'api_url': u'http://127.0.0.1:9101/v1', u'pack': u'examples'}}, 'input': {u'cmd': u\"secho 'hi'\", u'timeout': 60}, 'graph': {'directed': True, 'graph': [], 'nodes': [{'id': u'task1'}, {'id': u'noop'}], 'adjacency': [[{u'ref': 0, u'id': u'noop', u'key': 0, u'criteria': []}], []], 'multigraph': True}, 'spec': {'catalog': 'native', 'version': '1.0', 'spec': {u'input': [u'cmd', u'timeout'], u'tasks': {u'task1': {u'action': u'core.local cmd=<% ctx(cmd) %> timeout=<% ctx(timeout) %>', u'next': [{u'publish': [{u'stdout': u'<% result() %>'}]}]}}, u'description': u'A basic workflow that runs an arbitrary linux command.', u'version': 1.0, u'output': [{u'stdout': u'<% ctx(stdout) %>'}]}}, 'output': {u'stdout': {u'failed': True, u'stderr': u'bash: secho: command not found', u'return_code': 127, u'succeeded': False, u'stdout': u''}}}\r\n2019-07-12 09:38:43,795 140001394854000 INFO workflows [-] [5d288d6149b3d2af833a2991] Updating workflow execution from status \"running\" to \"succeeded\".\r\n2019-07-12 09:38:43,857 140001394854000 DEBUG workflows [-] [5d288d6149b3d2af833a2991] Updating workflow liveaction from status \"running\" to \"succeeded\".\r\n```"},"comment":{"url":"https://api.github.com/repos/StackStorm/st2/issues/comments/512032198","html_url":"https://github.com/StackStorm/st2/issues/4740#issuecomment-512032198","issue_url":"https://api.github.com/repos/StackStorm/st2/issues/4740","id":512032198,"node_id":"MDEyOklzc3VlQ29tbWVudDUxMjAzMjE5OA==","user":{"login":"m4dcoder","id":2767408,"node_id":"MDQ6VXNlcjI3Njc0MDg=","avatar_url":"https://avatars2.githubusercontent.com/u/2767408?v=4","gravatar_id":"","url":"https://api.github.com/users/m4dcoder","html_url":"https://github.com/m4dcoder","followers_url":"https://api.github.com/users/m4dcoder/followers","following_url":"https://api.github.com/users/m4dcoder/following{/other_user}","gists_url":"https://api.github.com/users/m4dcoder/gists{/gist_id}","starred_url":"https://api.github.com/users/m4dcoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m4dcoder/subscriptions","organizations_url":"https://api.github.com/users/m4dcoder/orgs","repos_url":"https://api.github.com/users/m4dcoder/repos","events_url":"https://api.github.com/users/m4dcoder/events{/privacy}","received_events_url":"https://api.github.com/users/m4dcoder/received_events","type":"User","site_admin":false},"created_at":"2019-07-16T22:53:07Z","updated_at":"2019-07-16T22:53:07Z","author_association":"CONTRIBUTOR","body":"We can update our documentation so this is clearer."}}
{"actor":{"display_login":"m4dcoder"}}