Destroy merge train car after branch deletion
What does this MR do and why?
Similarly to !165216 (merged),
this will fix the same issue for auto merge when checks pass.
Fixes #486479 (closed).
References
Please include cross links to any resources that are relevant to this MR This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
- #483097 (closed)
- https://gitlab.com/gitlab-com/ops-sub-department/section-ops-request-for-help/-/issues/458#note_2176262501
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
- Create an project with the following setup:
- Add this CI configuration:
my-job: rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" script: - sleep 120 - Open a merge request in the project, let the pipeline succeed
- Start a Rails console session and prepare:
project = Project.find_by_full_path(YOUR_PROJECT_PATH) user = User.first mr = project.merge_requests.find_by_iid(YOUR_MR_IID) service = AutoMerge::AddToMergeTrainWhenChecksPassService.new(project, user) - Add the MR to the merge train via
Mergebutton - Run this in the Rails console session to simulate the race condition:
service.abort(mr.reload, 'some reason') - Without this change, your MR is now stuck in an unmergable state: The
Mergebutton can be clicked, but just spins without action until reloading the page. (UsingSet to auto-mergewhile the MR train pipeline is still running also doesn't do anything.) With this change, you can start a new merge train via the button.
Edited by Manuel Grabowski