orquesta icon indicating copy to clipboard operation
orquesta copied to clipboard

Retries using with-items runs a retry even on objects that succeeded as well

Open soumyabk opened this issue 5 years ago • 5 comments

We use the with-items to loop over and run an action. If it fails for even one of them, it retries over all the items in the array again, instead of just retrying the failed ones.

For instance, if param1 was set to 1,2,3,4 in the below sample workflow:

version:                1.0
description:            Test retry workflow
input:
  - param1
  - slack_channel
tasks:
  split_list:
    action: core.noop
    next:
    - when: <% succeeded() %>
      do: print_val
      publish:
        - list_vals: <% ctx(param1).split(',') %>
  print_val:
    with: <% ctx(list_vals) %>
    action: core.local
    input :
      cmd : >
        val=<% item() %>;
        if [ $val -eq 2 ];then exit -1;fi
    retry:
      when: <% failed() %>
      count: 5
      delay: 2
    next:
      - when: <% succeeded() %>
        publish:
          - status: "SUCCESS"
      - when: <% failed() %>
        do:
          - send_failed_alert
        publish:
          - status: "FAILED"
  send_failed_alert:
    action: slack.chat.postMessage
    input:
      channel: "#<% ctx(slack_channel) %>"
      text: "ERROR: failed on param <% ctx(param1) %> failed"`

And here is the output of the run.

image

soumyabk avatar Apr 24 '20 22:04 soumyabk

In current implementation, the retry is scoped to the task so it retry the task and not the items in the case of with items. We can add an option in the retry spec to retry only failed items.

m4dcoder avatar Apr 24 '20 23:04 m4dcoder

The following is one possible solution for the retry spec to support per-item retry.

    retry:
      items:
        when: <% some condition on the action execution for the item %>
        count: 3
        delay: 1

m4dcoder avatar Apr 24 '20 23:04 m4dcoder

The following is one possible solution for the retry spec to support per-item retry.

    retry:
      items:
        when: <% some condition on the action execution for the item %>
        count: 3
        delay: 1

Your proposed solution per-item retry does not work.

kyildiz avatar Jun 10 '20 11:06 kyildiz

@kyildiz It was a proposal and not supported yet.

m4dcoder avatar Mar 12 '21 04:03 m4dcoder

you can wrap your action in a workflow and put the retry logic in the subworkflow for now as a workaround.

guzzijones avatar Mar 28 '24 19:03 guzzijones