atlantis: undiverged not working correctly as a plan requirement

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

When running atlantis plan on an out of date branch, it results in inconsistent behavior as seen below. I suspect the undiverged check is not running early enough. It should probably execute before any plans are run at all? My guess is that parallel planning is throwing it off.

image

Reproduction Steps

Set up a repo that plans multiple paths in parallel. Make an out of date PR Run atlantis plan

Environment details

  • Atlantis version: 0.27.0
  • Deployment method: ecs

Atlantis server-side config file:

- id: /.*/
  apply_requirements:  [approved, mergeable, undiverged]
  import_requirements: [approved, mergeable, undiverged]
  plan_requirements:   [undiverged]

Repo atlantis.yaml file:

parallel_plan: true
parallel_apply: true

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 6
  • Comments: 18 (11 by maintainers)

Most upvoted comments

True, however undiverged is already documented to only work if checkout strategy is merge.

Applies to merge checkout strategy only which you need to set via --checkout-strategy flag.

From https://www.runatlantis.io/docs/command-requirements.html#undiverged

I’m not sure we have the ability to detect divergence in a branch situation.

So maybe we remove support for undiverged as a plan requirement (i.e., have startup fail if it’s set, update docs). As noted it doesn’t work currently so we’re not losing much, and I don’t think in general it’s desirable.

Interested to hear from other commenters here @albertorm95 @xakraz @kpocius ?

EDIT: Additionally we maybe should have startup fail if undiverged is set as an apply/import requirement but checkout strategy is not set to checkout, since it’s not going to work 🤔

We currently use branch strategy, we have no problem with switching to merge.

undiverged only applies to the merge checkout strategy, so unless I’m misunderstanding something there’s no regression here.

The scenario you describe should be consistent with having an apply requirement for undiverged right?

Again, when using the merge checkout strategy, before actually running a plan, the content from the branch is “merged” with then fetched origin/main, so there’s already no way to plan without new updates to main. A plan requirement that prevented that from happening would defeat the purpose of the merge checkout strategy entirely, at which point you might as well use branch.

I’m still leaning towards just an update to documentation/config validation to clarify this is an apply-only requirement.

cc @GenPage @jamengual

PR is now behind main. engineer runs atlantis plan which works.

My understanding of https://www.runatlantis.io/docs/checkout-strategy.html#merge, and I was able to confirm this at least in a toy example, is that when you go to run that plan, it checks out main at origin then does the merge. So the actual plan that’s created is not behind. Is this not what you’re seeing?

Tested this on 0.27.1 with both parallel plan and apply turned off – it still goes ahead an happily plans the changes.