Skip to content

Automerge with multiple Atlantis instances causes premature PR merge #6302

@guyscher

Description

@guyscher

Bug Description

When running multiple Atlantis instances watching the same repository with automerge enabled, each instance independently decides to merge the PR once its own plans are all applied — without checking whether other instances still have unapplied plans. This causes premature merges, leaving plans from other instances unapplied.

Reproduction Steps

  1. Configure 2+ Atlantis instances watching the same repo (e.g., Instance A manages infra/networking/, Instance B manages infra/compute/)
  2. Enable automerge: true on all instances
  3. Create a PR that modifies root modules managed by both instances
  4. Selectively apply plans one instance at a time — e.g., apply all Instance A plans first
  5. Observe: Instance A merges the PR immediately after its plans are applied, even though Instance B still has unapplied plans

Expected Behavior

The PR should only be merged when all plans across all Atlantis instances have been successfully applied. Automerge should be aware of (or defer to) the state of other instances.

Actual Behavior

The first instance to complete all of its own applies triggers the merge, ignoring unapplied plans from other instances. This can lead to:

  • Unapplied infrastructure changes that were planned but never applied
  • Drift between the planned state and actual infrastructure
  • Silent failures where team members assume all changes were applied

Environment

  • Atlantis version: affects current versions with automerge enabled
  • Multiple Atlantis instances watching the same repository
  • Automerge enabled on all instances

Possible Solutions

  1. Cross-instance awareness: Atlantis could check GitHub commit statuses/checks from all instances before triggering automerge
  2. Documentation update: At minimum, warn users that automerge is not safe with multi-instance setups (update automerge docs)
  3. Post-workflow hook pattern: Provide guidance on using a post-apply webhook that checks all commit statuses before triggering merge via API

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions