Release Tools throws HTTP422 when attempting to merge
Problem Statement
When running the task security:merge
, we ran into an issue with a target MR, specifically, the inability to merge, with an HTTP422 coming from GitLab's API. Reference job: https://ops.gitlab.net/gitlab-org/release/tools/-/jobs/10437020
Timeline:
- We asked to trigger a new pipeline despite learning of a past successful pipeline:
2023-06-26 15:05:53.958262 D ReleaseTools::Security::MergeWhenPipelineSucceedsService -- Latest pipeline -- {:merge_request=>"https://gitlab.com/gitlab-org/security/gitlab/-/merge_requests/3330", :pipeline_id=>912016924, :status=>"success"}
2023-06-26 15:05:53.958279 I ReleaseTools::Security::MergeWhenPipelineSucceedsService -- Triggering pipeline for merged results -- {:merge_request=>"https://gitlab.com/gitlab-org/security/gitlab/-/merge_requests/3330"}
2023-06-26 15:06:23.775922 D ReleaseTools::GitlabClient -- [HTTParty] [2023-06-26 15:06:23 +0000] 200 "POST https://gitlab.com/api/v4/projects/15642544/merge_requests/3330/pipelines" -
2023-06-26 15:06:23.776093 I ReleaseTools::Security::MergeWhenPipelineSucceedsService -- Waiting for a merge request pipeline
- We then issues a MWPS, which fails
2023-06-26 15:06:31.872857 I ReleaseTools::Security::MergeWhenPipelineSucceedsService -- Merge request pipeline -- {:pipeline=>"https://gitlab.com/gitlab-org/security/gitlab/-/pipelines/912110405", :status=>"running"}
2023-06-26 15:06:31.872887 I ReleaseTools::Security::MergeWhenPipelineSucceedsService -- Setting MWPS -- {:merge_request=>"https://gitlab.com/gitlab-org/security/gitlab/-/merge_requests/3330"}
2023-06-26 15:06:32.495692 D ReleaseTools::GitlabClient -- [HTTParty] [2023-06-26 15:06:32 +0000] 422 "PUT https://gitlab.com/api/v4/projects/15642544/merge_requests/3330/merge" 37
2023-06-26 15:06:33.341373 D ReleaseTools::GitlabClient -- [HTTParty] [2023-06-26 15:06:33 +0000] 200 "GET https://gitlab.com/api/v4/projects/15642544/pipelines" -
2023-06-26 15:06:33.341544 D ReleaseTools::Security::MergeWhenPipelineSucceedsService -- Latest pipeline -- {:merge_request=>"https://gitlab.com/gitlab-org/security/gitlab/-/merge_requests/3330", :pipeline_id=>912110405, :status=>"running"}
Despite this failure, we do see it successfully set via the UI:
- We retry this 2 more times; for which fails each time.
Solutionizing
- Potential bug in GitLab's API where an API request to MWPS is not allowed if already set?
- Potential bug in release-tools where detection of MWPS is flawed leading us to send an improper API request?
Either way, MWPS was set, which release-tools should handle gracefully.