Skip to content

feat: replan between execution order groups during apply - #6766

Open
marcosaranda-appspace wants to merge 1 commit into
runatlantis:mainfrom
marcosaranda-appspace:feat/replan-between-execution-order-groups
Open

feat: replan between execution order groups during apply#6766
marcosaranda-appspace wants to merge 1 commit into
runatlantis:mainfrom
marcosaranda-appspace:feat/replan-between-execution-order-groups

Conversation

@marcosaranda-appspace

@marcosaranda-appspace marcosaranda-appspace commented Aug 13, 2026

Copy link
Copy Markdown

what

Adds an opt-in repo-level setting:

replan_between_execution_order_groups: true

When enabled, a broad atlantis apply will:

  1. Apply earlier execution_order_groups with the reviewed planfiles
  2. Re-run plan (and policy_check when configured) for later groups
  3. Apply those later groups with the refreshed planfiles

Default remains false, so existing plan-then-apply review semantics are unchanged.

why

Fixes #2243. Terragrunt (and similar) stacks plan dependents with mock_outputs while their parents do not exist yet. Atlantis then applies the stale mock planfile for the child after the parent apply. depends_on and execution_order_group only order work; they do not refresh planfiles.

Related: #6106, #6558 (pausing between groups is complementary, not a substitute).

safety and compatibility

  • Mid-apply replans set MidApplyReplan, reuse GetWorkingDir, and skip Clone/MergeAgain, so sibling planfiles in the pull workspace are never wiped or invalidated. Plan-stage PR requirements are also skipped, since apply requirements already ran and MergeAgain is intentionally not performed.
  • Mid-apply replans set SuppressVCSStatus and SuppressJobOutput, so project commit statuses do not flip to plan mid-apply.
  • Mid-apply plan and policy output does not enter apply ProjectResults, so apply PR comments and the apply DB status stay clean.
  • If an earlier group fails while the setting is enabled, later groups are skipped rather than refreshed against incomplete dependencies.
  • With the setting off, abort_on_execution_order_fail behavior is byte-for-byte the previous behavior, including the shared plan command path.
  • Distinct execution_order_group values are recommended. If every project shares group 0 with parallel_apply: true, Atlantis still runs a single wave and cannot replan between projects.

tests

  • New unit tests: replan enabled, disabled, replan failure, and earlier-apply-failure stopping later groups.
  • New unit test asserting the mid-apply plan uses GetWorkingDir, never Clone/MergeAgain, and skips plan-requirement revalidation.
  • Config round-trip test for the new key.
  • Whole repository suite green in ghcr.io/runatlantis/testing-env:latest (make test-all && make check-fmt), including server/controllers/events.
  • markdownlint-cli2 clean across runatlantis.io/**/*.md, and go vet clean on the touched packages.
  • Manual Terraform parent/child reproduction: child planned against a mock id, parent applied, then replan and apply wires the child to the real parent id.

notes for reviewers

  • Opt-in only, since maintainers have asked not to change default planfile semantics.
  • Mid-apply replan means later groups may apply a plan that was not the exact one commented on the PR. The docs call this out explicitly.
  • When all projects share one execution order group and run sequentially, replan only applies to projects that declare depends_on.
  • Happy to iterate on naming, or on whether the refreshed plan should pause for human review (which could combine with feat: pause apply between execution order groups #6666).

@dosubot dosubot Bot added feature New functionality/enhancement go Pull requests that update Go code labels Aug 13, 2026
@github-actions github-actions Bot added the docs Documentation label Aug 13, 2026
@marcosaranda-appspace
marcosaranda-appspace force-pushed the feat/replan-between-execution-order-groups branch 2 times, most recently from d874f2c to 7507031 Compare August 13, 2026 16:59
Add an opt-in repo setting so Atlantis can refresh later planfiles after
earlier execution order groups apply. This unblocks Terragrunt stacks that
plan dependents with mock_outputs and otherwise apply a stale plan (runatlantis#2243).

The feature is off by default and is designed to leave existing flows alone:
- Mid-apply replan reuses the pull working tree and skips Clone/MergeAgain
  so sibling planfiles stay intact.
- Mid-apply replan suppresses VCS and job status noise, and its plan and
  policy_check output does not enter apply results, PR comments, or the
  apply DB status.
- With the setting enabled, a failed group stops later groups instead of
  refreshing against incomplete dependencies.
- Historical abort_on_execution_order_fail behavior is unchanged when the
  setting is off.

Assisted-by: Cursor <noreply@cursor.com>
Signed-off-by: marcos.aranda <marcos.aranda@appspace.com>
@marcosaranda-appspace
marcosaranda-appspace force-pushed the feat/replan-between-execution-order-groups branch from 7507031 to f51960b Compare August 13, 2026 17:18
@pseudomorph

Copy link
Copy Markdown
Contributor

Hi @marcosaranda-appspace -- Thanks for the submission here. I think something along these lines is needed. But, I'd like to ensure that the ultimate approach aligns with the long-term goals of the project.

Some things that comes to mind is whether to surface the plan delta on re-plan, or if automatically applying the refreshed plan, if there should be any criteria which toggles proceed with auto-apply vs bail and show the plan.

I'll try to find some time to look over this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation feature New functionality/enhancement go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

atlantis + terragrunt: dependent modules can't be applied in one go

2 participants