GitLab: combined `atlantis/apply` status stays `running` forever when an MR is merged with unapplied plans
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
While a merge request is open, Atlantis keeps the combined atlantis/apply commit status at running as long as planned projects remain unapplied. That is correct and useful: it stops the MR from merging with unapplied changes.
The problem is that this state can outlive the MR. If the MR is merged anyway (apply requirements permitting, or after a partial apply of only some projects), or closed without applying, nothing ever finalizes the combined status. On GitLab the external pipeline that carries it then shows running on the merged commit forever. The state has lost its purpose (there is no merge left to block), it suggests activity that is not happening, and it accumulates: these pipelines never reach a terminal state on their own, and GitLab's stuck-pipeline handling does not touch jobless external pipelines.
Live example from our instance: an MR with two planned projects was merged after applying only one of them. Eight days later the merged commit's pipeline still shows atlantis/apply = running, and it will stay that way indefinitely.
Reproduction Steps
- GitLab project, MR with two or more Atlantis projects.
atlantis planall of them;atlantis applyonly one.- Merge the MR (or close it).
- The combined
atlantis/applystatus, and with it the external pipeline on the head commit, staysrunningforever.
Logs
Not applicable: nothing fails, so nothing is logged. The behaviour is the absence of a final status write after the MR is closed or merged.
Environment details
- Atlantis v0.47.1 (
ghcr.io/runatlantis/atlantis:v0.47.1-debian), ECS Fargate - GitLab self-managed 19.4.1
- Terragrunt custom workflow, config generated by terragrunt-atlantis-config
Additional Context
- Atlantis already reacts to MR close/merge events (locks and working directories are cleaned up), so there is a natural place to finalize the status.
- Suggested behaviour: when an MR is merged or closed with the combined
atlantis/apply(oratlantis/plan) status still pending/running, write a terminal state. GitLab's commit status API acceptscanceled(verified on 19.4.1), which describes the situation precisely: the work was abandoned, it neither succeeded nor failed. A description like "merge request closed with unapplied plans" would make it self-explanatory. - The wrinkle: Atlantis's internal status model only knows pending/success/failed, and not every VCS has a
canceledcommit state (GitHub does not), so this would be a per-VCS mapping decision. We wanted the maintainers' view on the direction before attempting any code. If the direction is agreed, we are happy to test a patch against our live GitLab 19.4.1, as we did for #6932. - Related observation, noted here for completeness: the
/api/planand/api/applyendpoints set the combined statuses to pending and never write a terminal state afterwards (server/controllers/api_controller.go,apiPlan/apiApply), so API-triggered runs against an MR strandatlantis/plan/atlantis/applyatrunningfrom the start. We noticed it while investigating, but we do not use these endpoints and do not have the capacity to propose a fix for that part; mentioning it in case it deserves its own issue. - Background: we ran into this while chasing stranded
runningpipelines on our repos (#6871, and the diagnosis that led to closing #5368).
Source: runatlantis/atlantis