Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: when using order group, abort plan/apply if any fail #3323

Merged
merged 5 commits into from
May 12, 2023

Conversation

oysteingraendsen
Copy link
Contributor

@oysteingraendsen oysteingraendsen commented Apr 12, 2023

what

  • Break out of order group loop if any command fails. This applies only when using parallel apply/plan and execution order group.

why

  • Atlantis supports execution groups when using parallel apply/plan, but does not stop if there are any errors
    in a prior execution group. This should happen in my opinion.

tests

  • I have added tests for execution order groups
  • I have added tests that ensures that execution stops on failed apply for the next execution group

references

@oysteingraendsen oysteingraendsen changed the title feat: when using ordergroup, abort plan/apply if any fail feat: when using order group, abort plan/apply if any fail Apr 12, 2023
@oysteingraendsen oysteingraendsen force-pushed the order-group-abort-on-fail branch from bc1bf17 to 51f7b76 Compare April 12, 2023 12:50
@oysteingraendsen oysteingraendsen marked this pull request as ready for review April 12, 2023 12:51
@oysteingraendsen oysteingraendsen requested a review from a team as a code owner April 12, 2023 12:51
@github-actions github-actions bot added the go Pull requests that update Go code label Apr 12, 2023
@@ -81,6 +81,9 @@ func runProjectCmdsParallelGroups(
for _, group := range groups {
res := runProjectCmdsParallel(group, runnerFunc, poolSize)
results = append(results, res.ProjectResults...)
if res.HasErrors() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could a check be ran here against an opt-out flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add a flag if you want that. Should that be added on a repo level? In the issue that I referred to, the suggestion was setting this as the expected behaviour.

I'm not sure I see when you would want to opt out of this as you want it to run in a given order, but I'm all ears for what you guys want 👍

Copy link
Contributor

@jukie jukie Apr 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an official maintainer so my opinion is lower than what @krrrr38 mentioned in the issue 😄
It may not be worth it but my thought process was that it changes existing behavior so if any users don't want this it would break their workflow.
And a repo level flag would probably be the most flexible

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @jukie , repo level will be nicer and allows the user to change the behaviour by a flag

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would anyone want their execution group to continue if it has errors in between?

@github-actions github-actions bot added the docs Documentation label Apr 14, 2023
@GenPage
Copy link
Member

GenPage commented Apr 16, 2023

There's another PR to address this that I think is more involved.

#3292 solves essentially what you are proposing, I think it might be more prudent to utilize that feature and deprecate execution_order_group

@nitrocode
Copy link
Member

The features may be able to work together as this comment points out

#3292 (comment)

@oysteingraendsen
Copy link
Contributor Author

The features may be able to work together as this comment points out

#3292 (comment)

I'll just stay put until you figure out if this is going to be useful or not ;)

@nitrocode
Copy link
Member

Nevermind. I was corrected in the other PR. It looks like the PR author and GenPage plan to deprecate the execution_order_group with the new depends_on proposal.

@nitrocode
Copy link
Member

On the other hand, the terragrunt-atlantis-config repo is currently setup to use the execution order and people who currently use this also complain that a single error will not stop the pipeline. Even if execution-order will be deprecated, i think we should still fix this bug for current users. Then we can have the depends-on implemented and slowly deprecate execution-order thus giving time for people to migrate.

@nitrocode
Copy link
Member

cc @jamengual @GenPage thoughts?

We did the same for the whitelist to allowlist deprecations as well. Slow deprecation to allow people to migrate.

@jamengual
Copy link
Contributor

yes, we can do the same

@GenPage
Copy link
Member

GenPage commented Apr 23, 2023

Sgtm

@oysteingraendsen oysteingraendsen force-pushed the order-group-abort-on-fail branch from 05b5910 to 5de44bf Compare April 27, 2023 08:10
@nitrocode
Copy link
Member

@oysteingraendsen can you confirm that you have tested this, not only in unit tests, but end to end in your own setup? If you could test

  • with the flag
    • with all successful jobs that does not early exist
    • with a broken intermediary job that early exits
  • without the flag
    • with all successful jobs
    • with a broken intermediary job that does NOT early exit (status quo)

@oysteingraendsen
Copy link
Contributor Author

@oysteingraendsen can you confirm that you have tested this, not only in unit tests, but end to end in your own setup? If you could test

* with the flag
  
  * with all successful jobs that does not early exist
  * with a broken intermediary job that early exits

* without the flag
  
  * with all successful jobs
  * with a broken intermediary job that does NOT early exit (status quo)

Sorry about the delay. I have been a bit caught up lately.

I have tested the points you mentioned and it works for apply, but not for plan. I'll write some tests for plan as well to figure out why it does not work there too.

@GenPage GenPage added this to the v0.24.0 milestone May 6, 2023
@GenPage
Copy link
Member

GenPage commented May 6, 2023

@oysteingraendsen If you need help troubleshooting the tests, feel free to ping me here or in Slack.

@GenPage GenPage added the needs tests Change requires tests label May 6, 2023
@oysteingraendsen oysteingraendsen force-pushed the order-group-abort-on-fail branch from c89e05f to ec0644b Compare May 9, 2023 11:01
GenPage
GenPage previously approved these changes May 10, 2023
Copy link
Member

@GenPage GenPage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, other than the nitpick comment

nitrocode
nitrocode previously approved these changes May 10, 2023
@oysteingraendsen oysteingraendsen force-pushed the order-group-abort-on-fail branch from 89d5731 to 8e4026d Compare May 11, 2023 18:58
@oysteingraendsen
Copy link
Contributor Author

I just verified that it now works. It's ready to be merged from my end now, @GenPage

@GenPage GenPage merged commit 4e867fc into runatlantis:main May 12, 2023
@oysteingraendsen oysteingraendsen deleted the order-group-abort-on-fail branch May 12, 2023 17:25
mtavaresmedeiros pushed a commit to mtavaresmedeiros/atlantis that referenced this pull request Jul 3, 2023
…is#3323)

* feat: when using order group, abort plan/apply if any fail

* feat: add 'abort_on_execution_order_fail' flag on repo level

* feat: use runProjectCmdsParallelGroups in version_command_runner

* chore: add plan tests

---------

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
…is#3323)

* feat: when using order group, abort plan/apply if any fail

* feat: add 'abort_on_execution_order_fail' flag on repo level

* feat: use runProjectCmdsParallelGroups in version_command_runner

* chore: add plan tests

---------

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
…is#3323)

* feat: when using order group, abort plan/apply if any fail

* feat: add 'abort_on_execution_order_fail' flag on repo level

* feat: use runProjectCmdsParallelGroups in version_command_runner

* chore: add plan tests

---------

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation go Pull requests that update Go code needs tests Change requires tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

abort atlantis workflow when earlier execution_order_group fails
6 participants