k1LoW / runn

runn is a package/tool for running operations following a scenario.
https://runn.run
MIT License
421 stars 31 forks source link

[Question] How does the --fail-fast option affect the runn run behavior? #1032

Closed h6ah4i closed 1 day ago

h6ah4i commented 1 week ago

I expected the book 3.yaml not to run when the --fail-fast option is specified in the following setup. However, the command output shows that the book 3.yaml is still being evaluated. Am I misunderstanding how this command-line option works?

❯ runn run --fail-fast './*.yaml'
.F.

1) 2.yaml 5a1a25bd510cabac2c55504c9f80759ca4ca935b
  Failure/Error: test failed on "[No Description]".steps.forceFail: condition is not true

  Condition:
    false

    │

Error: step not found: 0

1.yaml

steps:
  forcePass:
    test: |
      true

2.yaml

steps:
  forceFail:
    test: |
      false

3.yaml

steps:
  forcePass:
    test: |
      true
k2tzumi commented 4 days ago

It might be easier to understand if you add the verbose option.

% runn run --fail-fast './*.yaml' --verbose
=== [No Description] (1.yaml)
    --- (forcePass) ... ok
=== [No Description] (2.yaml)
    --- (forceFail) ... fail
        Failure/Error: test failed on "[No Description]".steps.forceFail: condition is not true

        Condition:
          false

          │

=== [No Description] (3.yaml)
    --- (forcePass) ... ok
=== Generated by `runn new` (deptrac.yaml)

1) 2.yaml 5a1a25bd510cabac2c55504c9f80759ca4ca935b
  Failure/Error: test failed on "[No Description]".steps.forceFail: condition is not true

  Condition:
    false

    │

Error: step not found: 0

Parallel execution in goroutines when multiple runbooks are specified and already started processes will continue to run until completion; when the fail-fast option is enabled, the context is canceled to prevent new processes from starting when an error occurs, but the already started processing is not canceled.

https://github.com/k1LoW/runn/blob/main/operator.go#L1690-L1712

@k1LoW In order to cancel a process that has already started, I wonder if it is feasible to check for context cancellation within each goroutine and abort the process appropriately?

k1LoW commented 3 days ago

Hmmm. I think that since sometime ago, --fail-fast is not behaving as intended!

k1LoW commented 3 days ago

In order to cancel a process that has already started, I wonder if it is feasible to check for context cancellation within each goroutine and abort the process appropriately?

Maybe we should consider it to make --fail-fast the intended behavior.

k1LoW commented 1 day ago

@h6ah4i Thank you for your report!

Fixed at v0.119.2.

$ ls
1.yml   2.yml   3.yml
$ runn -v
runn version 0.119.2
$ runn run *.yml --fail-fast
.FS

1) tmp/2.yml f5274803c3f42fcbba30536e0cc1143e3e43811d
  Failure/Error: test failed on "[No Description]".steps.forceFail: condition is not true

  Condition:
    false

    │

Error: step not found: 0
$