runatlantis / atlantis

Terraform Pull Request Automation
https://www.runatlantis.io
Other
7.73k stars 1.05k forks source link

Only delete the plan that failed when automerge is enabled #3002

Open lattwood opened 1 year ago

lattwood commented 1 year ago

Community Note


Overview of the Issue

Having automerge enabled causes Atlantis to delete all plans in a batch if even a single plan fails.

They shouldn't be deleted, because a user can retry just the failed plans.

Currently, you have to re-plan specifically the ones that succeeded originally, and then retry the failed ones.

Additional Context

https://github.com/runatlantis/atlantis/blob/7ca6b01aac6269478cbb3b50dc83e0ed8ba08a1d/server/events/plan_command_runner.go#L135-L139

nitrocode commented 1 year ago

@lattwood what i don't fully understand is why does automerge require all plans to succeed? If a single plan fails, it will show one of the plans as failed and if a subsequent apply is performed, it ahould fail to apply because of the plans had failed...

@lattwood please try to change the logic in your fork and try your new version. See if it doesn't return any mixed results. The new fork works fairly well. If you fork and then add updates to main, an action will run to upload your own dev tag image to your ghcr container repository.

Dawnflash commented 1 year ago

I see it referenced here.

This was requested by users
because when automerge is enabled, they want to enforce that a pull
request's changes have been fully applied. They asked that plans not be
allowed to be applied "piecemeal" and instead, all plans must be
generated successfully prior to allowing any plans to be applied.

Personally I'd say this is not a great solution. I agree that having 1/30 plans or so fail due to network gnomes and having to do it all over again isn't very pleasing. I think Atlantis already tracks failed plans in its state (even if just for VCS status purposes) so the automerge logic could either

WJay-tec commented 9 months ago

I am facing the exact same issue that @lattwood is having, wondering if its intended by design? @nitrocode

rushi47 commented 7 months ago

@WJay-tec

I am facing the exact same issue that @lattwood is having, wondering if its intended by design? @nitrocode

Same issue. Is it possible to maybe not discard the plan for individual projects ?

mjagielka commented 6 months ago

Looks like we have exactly the same problem ;-/ Especially when you have 3 modules in one PR with dependencies for example : you have to create GCP storage to be able to add permissions to GCP storage .. always 1x plan will failed in PR as storage have to be created before permissions which is obvious

shkamensky commented 3 months ago

Thanks @lattwood for pointing me in the right direction. I created a PR for this.

https://github.com/runatlantis/atlantis/pull/4709