Multiple plans with a targeted apply with auto merge will incorrectly merge pr
Opened this issue ยท 2 comments
Community Note
- Please vote on this issue by adding a ๐ reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
- If you are interested in working on this issue or have submitted a pull request, please leave a comment.
Overview of the Issue
Reproduction Steps
If the following is run
atlantis plan
And it affects multiple resources.
aws_s3_bucket.one
aws_s3_bucket.two
If this is run, the targeted apply will merge the pr leaving the other resource to be applied on a subsequent pr
atlantis apply -- -target='aws_s3_bucket.one'
Logs
Environment details
- Atlantis version: 0.21.0
--automerge
https://www.runatlantis.io/docs/server-configuration.html#automerge
Additional Context
atlantis/server/events/vcs/github_client.go
Line 499 in db9f022
atlantis/server/events/automerger.go
Line 35 in db9f022
atlantis/server/events/automerger.go
Lines 47 to 53 in db9f022
The hasTargetFlag function result could be passed down to the automergeEnabled. If the flag is true then we can set automerge to false.
Well this is interesting. Looks like targeted applies were previously prevented but perhaps this block is only caught with atlantis apply -target
convention and not with the atlantis apply -- -target
convention.
Related pr #403
workaround: use --auto-merge-disabled
Either use a naked plan and targeted apply
atlantis plan
atlantis apply --auto-merge-disabled -- -target='aws_s3_bucket.one'
or a targeted plan and a naked apply
atlantis plan -- -target='aws_s3_bucket.one'
atlantis apply --auto-merge-disabled
atlantis/server/events/comment_parser.go
Line 40 in db9f022
atlantis/server/events/comment_parser.go
Lines 333 to 335 in db9f022
Hello,
Workaround works well when having 1 project in the repository or if targeted plan/apply is run in last position, after all other projects has been applied with -p project
.
Otherwise, if targeted plan is run first for example ; even with auto-merge-disabled flag, and another project is applied, then the PR is automerged
Is an approach where targeted plan generate failed status check considered? Or maybe an option to allow not considering a targeted plan/apply as a valid commit check?
We'd need to somehow check if -target is in the comment and if so, add an empty file like .terraform-targeted so when you atlantis apply, it checks if the file exists. If the file exists, do not auto merge. If it doesnt exist, automerge unless the automerge flag is passed.