Required Approvals for MR Approval Rules not blocking MR merge
Summary
Customer has experienced multiple intermittent instances on GitLab SaaS where MR approval rules requiring approval are not applied consistently, and MRs can be merged without required approvals.
See ZenDesk ticket (internal only).
For the MR that was merged without required approval, the approval state in the UI shows Requires 1 approval from x
, and it lists the approval rule with Approvals 0 of 1
.
The approvedByEE
GraphQL query returns the following for the MR:
...
"approved": false,
"approvalsLeft": 1,
"approvalsRequired": 3,
"approvalState": {
...
"rules": [
{
"id": "gid://gitlab/ApprovalMergeRequestRule/REDACTED",
"approved": true,
"approvalsRequired": 2,
"name": "All Members",
"type": "ANY_APPROVER",
"__typename": "ApprovalRule"
},
{
"id": "gid://gitlab/ApprovalMergeRequestRule/REDACTED",
"approved": false,
"approvalsRequired": 1,
"name": "REDACTED",
"type": "REGULAR",
"__typename": "ApprovalRule"
}
],
...
And the readyToMergeEE
GraphQL query returns the following:
...
"detailedMergeStatus": "NOT_APPROVED",
...
"mergeable": false,
...
"mergeError": null,
...
In another MR, the approval rule with required approvals was set to optional, showing an approvalsRequired
of zero instead of 1
for the approval rule:
...
"approved": true,
"approvalsLeft": 0,
"approvalsRequired": 2,
...
"rules": [
{
"id": "gid://gitlab/ApprovalMergeRequestRule/REDACTED",
"approved": true,
"approvalsRequired": 2,
"name": "All Members",
"type": "ANY_APPROVER",
"__typename": "ApprovalRule"
},
{
"id": "gid://gitlab/ApprovalMergeRequestRule/REDACTED",
"approved": true,
"approvalsRequired": 0,
"name": "REDACTED",
"type": "REGULAR",
"__typename": "ApprovalRule"
}
],
Steps to reproduce
This problem is intermittent and cannot be readily reproduced. I was not able to reproduce this on GitLab SaaS.
- Add an MR approval rule for the project for
All protected branches
with a few named individuals as approvers, and a required approval count > 1 - Change
All eligible users
approval rule to have a required approval count > 1 - Create MR and confirm required approvals
- Satisfy approvals for
All eligible users
approval rule, but not the second approval rule - Attempt to merge MR via the UI
Example Project
What is the current bug behavior?
MR approval rule with required approvals not blocking MR merge
What is the expected correct behavior?
MR approval rule with required approvals blocks MR merge
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)