Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atlantis Apply Fails on GitLab v16.10 When the Merge Request Branch Needs Rebasing #4390

Closed
X-Guardian opened this issue Mar 28, 2024 · 0 comments 路 Fixed by #4402
Closed

Atlantis Apply Fails on GitLab v16.10 When the Merge Request Branch Needs Rebasing #4390

X-Guardian opened this issue Mar 28, 2024 · 0 comments 路 Fixed by #4402
Labels
bug Something isn't working

Comments

@X-Guardian
Copy link
Contributor

X-Guardian commented Mar 28, 2024

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

In Gitlab if:

  • The Gitlab version is 16.10.0 or above
  • The repo has the merge commit with semi-linear history or fast-forward merge methods enabled
  • The merge request branch is behind the target branch by one or more commits

Then the atlantis apply command on the MR will fail with the following error:

Apply Failed: Pull request must be mergeable before running apply.

Logs

Logs
[DBUG] Getting GitLab merge request 31
[DBUG] GET /projects/sheather/test/merge_requests/31 returned: 200
[DBUG] Updating GitLab commit status for 'atlantis/apply' to 'pending'
[DBUG] Getting GitLab merge request 31
[DBUG] GET /projects/sheather/test/merge_requests/31 returned: 200
[DBUG] Head pipeline found for merge request 31, source 'merge_request_event'. refTarget 'refs/merge-requests/31/head'
[DBUG] POST /projects/sheather/test/statuses/91a7ea6756cee6e9e62ab72665556c363bbf9af7 returned: 201
[DBUG] Checking if GitLab merge request 31 is approved
[DBUG] GET /projects/sheather/test/merge_requests/31/approvals returned: 200
[DBUG] Checking if GitLab merge request 31 is mergeable
[DBUG] GET /projects/sheather/test/merge_requests/31 returned: 200
[DBUG] GET /projects/2 returned: 200
[DBUG] GET /projects/2/commits/91a7ea6756cee6e9e62ab72665556c363bbf9af7/statuses returned: 200
[DBUG] Checking if GitLab supports detailed merge status
[DBUG] Getting GitLab version
[DBUG] GET /version returned: 200
[DBUG] building config based on server-side config
[DBUG] setting apply_requirements: [mergeable] from repos[1], id: /.*/
[DBUG] setting workflow: "default" from default server config
[DBUG] setting allowed_overrides: [] from default server config
[DBUG] setting custom_policy_check: false from default server config
[DBUG] setting repo_locking: true from default server config
[DBUG] setting policy_check: false from default server config
[DBUG] setting plan_requirements: [] from default server config
[DBUG] setting import_requirements: [] from default server config
[DBUG] setting allow_custom_workflows: false from default server config
[DBUG] setting delete_source_branch_on_merge: false from default server config
[DBUG] Building project command context for apply
[DBUG] Found required_version setting of ">=1.3.9"
[DBUG] Listing Terraform versions available at: https://releases.hashicorp.com/terraform
[INFO] Detected module requires version: 1.7.5
[DBUG] Updating GitLab commit status for 'atlantis/apply: live/aws/123456789012/develop/eu-west-2/stack11/default' to 'pending'
[DBUG] Getting GitLab merge request 31
[DBUG] GET /projects/sheather/test/merge_requests/31 returned: 200
[DBUG] Head pipeline found for merge request 31, source 'merge_request_event'. refTarget 'refs/merge-requests/31/head'
[DBUG] POST /projects/sheather/test/statuses/91a7ea6756cee6e9e62ab72665556c363bbf9af7 returned: 201
[DBUG] Updating GitLab commit status for 'atlantis/apply: live/aws/123456789012/develop/eu-west-2/stack11/default' to 'failed'
[DBUG] Getting GitLab merge request 31
[DBUG] GET /projects/sheather/test/merge_requests/31 returned: 200
[DBUG] Head pipeline found for merge request 31, source 'merge_request_event'. refTarget 'refs/merge-requests/31/head'
[DBUG] POST /projects/sheather/test/statuses/91a7ea6756cee6e9e62ab72665556c363bbf9af7 returned: 201
[EROR] Failure running apply operation: Pull request must be mergeable before running apply.
[DBUG] Hiding previous plan comments for command: 'Apply', directory: ''
[DBUG] Hiding previous command comments on GitLab merge request 31
[DBUG] /projects/sheather/test/merge_requests/31/notes
[DBUG] GET /projects/sheather/test/merge_requests/31/notes returned: 200
[DBUG] Updating merge request note: Repo: 'sheather/test', MR: '31', comment ID: '749'
[DBUG] PUT /projects/sheather/test/merge_requests/31/notes/749 returned: 200

Environment details

  • Atlantis version: 0.27.2

Additional Context

Gitlab have introduced the following new detailed merge statuses in MR !144729 which was released in v16.10.0:

  • conflict
  • need_rebase.

Reference: GitLab MR Merge Status

In previous versions of GitLab, merge requests in this state return mergeable in the detailed merge status.

The need_rebase status needs adding to the list of acceptable merge statuses that Atlantis checks for in the GitLab client PullIsMergeable function here:

if ((supportsDetailedMergeStatus &&
(mr.DetailedMergeStatus == "mergeable" ||
mr.DetailedMergeStatus == "ci_still_running" ||
mr.DetailedMergeStatus == "ci_must_pass")) ||

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant