Merge Request approval lost if approved too quickly after commit
Summary
When automating MR creation and approval, prior approvals are lost if approving the MR too soon after committing to the source branch. A customer experienced this issue with their own automation, however GitLab Support have reproduced this behaviour on SaaS using a simple script. If a sleep 60
is added prior to creating and approving the MR, the approvals are not lost.
Steps to reproduce
- Create a new project
- Implement and execute a script that does the following in order:
- Creates a branch
- Adds a commit to the branch
- Creates an MR from the source branch
- Creates an MR level approval rule
- Approves the MR as one of the users specified in the approval rule (this can be done in the script or manually afterwards)
- Add a
sleep 60
between adding the commit and creating the MR
Example Project
What is the current bug behavior?
Approval is made initially, a system note is added to the MR to confirm the approval has been made. However, after a refresh, the approval is gone (the system note remains).
What is the expected correct behavior?
Approval is made, a system note is added to the MR to confirm approval has been made. Approval remains.
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)