StackStorm / StackStorm/st2

Workflow withItems fails if 1 of the actions fail

Open
#5,971 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
6.5k
Forks
787
PR merge metrics
No merged PRs in 30d

Description

Discussed in https://github.com/StackStorm/st2/discussions/5970

Originally posted by glafkosch May 1, 2023
I am making dynamically generated worker requests with make_worker_requests task and passing those to another task run_linked_workers which runs for each item the action tf.run-worker-and-store-result.

The run_linked_workers task runs various worker checks for my project such as sslcheck, webcheck, dbcheck, etc. Everything works well if all return success but if even one check fails which is normal to fail in my case then the whole task fail.

As per documentation: "All action executions must complete successfully for the task to reach a succeeded state. If one or more action executions fail, then the task will result in a failed state."
ref: https://docs.stackstorm.com/orquesta/languages/orquesta.html#with-items-model

Is there any solution to solve this? Maybe is possible to introduce an additional variable to withItems if it should fail or succeed?

make_worker_requests:
action: tf.make_worker_requests
input:
target: <% ctx().target %>
target_type: <% ctx().target_type %>
services: "{{ ctx().services }}"
step: <% ctx().step %>
scan_id: <% ctx().scan_id %>
next:
- when: <% succeeded() %>
publish:
- portscan_linked_worker_requests: <% result().result %>
do: run_linked_workers
- when: <% failed() %>
publish:
- errors: <% ctx().errors + [dict(summary=>"Unable to make worker requests.", detail=>result())] %>
do:
- fail

run_linked_workers:
with:
items: <% ctx().portscan_linked_worker_requests %>
action: tf.run-worker-and-store-result
input:
worker_request: <% item() %>
next:
- when: <% succeeded() %>
publish:
- lwo: <% result() %>
- when: <% failed() %>
publish:
- errors: <% ctx().errors + [dict(summary=>"Unable to run linked workers.", detail=>result())] %>
do:
- fail

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with discussion #5970 and the Orquesta with-items model documentation linked in the issue. Review the shown make_worker_requests and run_linked_workers workflow, then clarify the desired behavior when one linked action fails. Done would require an agreed failure policy or configuration and a documented way to verify mixed success and failure outcomes.

Written by the indexing model from the issue text.

Assessment

Domain
devops
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.