Understanding how delay works

Can anyone explain how delay works within a workflow? Does the position of the delay in a specific action matter, or does it always process specific items in a specific order (like cmd always runs first, then delay, etc).

As a bit more information on what I’m attempting to accomplish, I’m writing a workflow which will remotely reboot a system, pause for some period of time (30 - 60 seconds), then a subsequent action will grab the last reboot time from the targeted system and if it is within an acceptable amount of time, it will finish out the workflow as successful, otherwise it will fail out of the workflow.

TIA

Assuming you’re talking about Orquesta.

Quick Answers To Your Specific Questions

Does the position of the delay in a specific action matter?

No, the ordering of the task dictionary keys (which include delay and retry) do not matter.

or does it always process specific items in a specific order (like cmd always runs first, then delay, etc)

There are two ways to delay a task, and the answer to this question depends on the exact type of delay you are talking about (see below).

Task Delay

Specifying a delay on a task will prevent a task from executing for a specified time. The delay is applied before the task is executed, and is only applied once.

Documentation

https://docs.stackstorm.com/orquesta/languages/orquesta.html#task-model

Example Workflow

# ...

tasks:
  task1:
    delay: 10  # seconds
    action: ...
      input:
        ...
    next:
      ...

Task Retry

Task retry delay specifies the amount of delay between retry executions of a task. This is only applied when the task is retried, so if the task is successful the first time it is tried, this setting will have no effect.

Documentation

https://docs.stackstorm.com/orquesta/languages/orquesta.html#task-retry-model

Example

# ...

tasks:
  task1:
    retry:
      delay: 5  # seconds
      count:  3
    action: ...
      input:
        ...
    next:
      ...

Differences

I believe that the task delay is only applied once, even if the task is retried.

The task retry delay is applied every time the task is retried, but is not applied before the initial execution attempt.

Skeleton Workflow For You

...

vars:
  - acceptable_amount_of_time: ...

tasks:
  reboot_system:
    action: ...
    # Retry up to three times (so four times total), delaying each non-first attempt by 30 seconds
    retry:
      delay: 30  # seconds
      count: 3
    next:
      - when: <% success() %>
        do: grab_last_reboot_time
      - when: <% failed() %>
        do: ...
  grab_last_reboot_time:
    delay: 60  # seconds
    action: ...
    next:
      - when: <% result().something < acceptable_amount_of_time %>  # <-- modify this
        do: noop
      - when: <% result().something >= acceptable_amount_of_time %> # <-- modify this
        do: fail