-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: enabling pending apply status when any of the projects has changes to… #5926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rjmsilveira
wants to merge
10
commits into
runatlantis:main
Choose a base branch
from
rjmsilveira:enable-pending-apply-status-jobs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: enabling pending apply status when any of the projects has changes to… #5926
rjmsilveira
wants to merge
10
commits into
runatlantis:main
from
rjmsilveira:enable-pending-apply-status-jobs
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7888091 to
804f27d
Compare
…ges to be applied Signed-off-by: Ricardo Silveira <[email protected]>
804f27d to
862f0b8
Compare
…rojects has changes to be applied Signed-off-by: Ricardo Silveira <[email protected]>
cf520d4 to
c96562e
Compare
|
This feature is a must-have for me. |
|
Thanks for adding this, I like it. |
Signed-off-by: Ricardo Silveira <[email protected]>
…unatlantis#5966) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Ricardo Silveira <[email protected]>
ce9f28d to
7825027
Compare
lukemassa
approved these changes
Nov 21, 2025
| DiscardApprovalOnPlan bool | ||
| pullReqStatusFetcher vcs.PullReqStatusFetcher | ||
| SilencePRComments []string | ||
| PendingApplyStatusFlag bool |
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the time this variable is being used it's no longer a "flag", a better name might be just PendingApplyStatus.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
This MR restores the ability to set commit status to pending when there are planned Terraform changes that haven't been applied yet. This feature is now:
GitLab-specific (controlled by the --gitlab-pending-apply-status flag)
Opt-in (defaults to false to maintain backward compatibility)
Provides better visibility into MR readiness by blocking merges until all applies are completed
Why
When enabled, this feature prevents GitLab merge requests from being merged prematurely by setting the commit status to pending when:
The status transitions:
This addresses a common workflow requirement where teams want to ensure all infrastructure changes are actually applied before allowing the MR to merge, preventing situations where planned changes are approved but never executed.
Why GitLab-only and opt-in?
The original implementation (#2053) caused issues (#2138) with race conditions where apply status would appear before plans completed, leading to confusion and stuck PRs. The feature was reverted in #2173.
Since then, Atlantis has significantly improved its event ordering and status update handling. However, to ensure maximum safety and backward compatibility, this restoration:
Limits scope to GitLab - where the feature is most requested and tested
Requires explicit opt-in - prevents unexpected behavior changes for existing users
Preserves existing behavior - when disabled or on other VCS platforms, no status updates occur for unapplied plans
Tests
Added comprehensive test coverage in TestPlanCommandRunner_GitlabPendingApplyStatus:
✅ GitLab + flag enabled + unapplied plans → Pending status
✅ GitLab + flag disabled + unapplied plans → No status update (backward compatible)
✅ GitLab + all plans applied → Success status
✅ GitHub/Bitbucket + flag enabled → No status update (GitLab-only feature)
✅ GitLab + apply errors → Failed status
All existing tests pass, ensuring backward compatibility is maintained.
References
Original feature (2021): https://github.com/runatlantis/atlantis/pull/2053/files
Issue reports (race conditions): https://github.com/runatlantis/atlantis/issues/2138
Feature revert (2022): https://github.com/runatlantis/atlantis/pull/2173/files
Key improvements since the original implementation:
The latest Atlantis codebase now handles event ordering much more reliably. The race condition issues that caused the original revert (where apply status would appear before plans properly finished) have been resolved through improved event sequencing. This makes it safe to reintroduce the feature with proper safeguards (opt-in flag + VCS-specific implementation).
Configuration:
See updated documentation in server-configuration.md.
This approach provides the requested functionality while learning from past issues and ensuring a smooth, safe rollout for teams that need this workflow enforcement.