Block premature merges on ref-based pipeline creation (FF)
What does this MR do and why?
This is part 2 of a 3-MR stack that reinstates !232296 (merged), stacked on MR 1 (scaffolding) !256819 (merged). It adds the track_ref_pipeline_creation flag. It reads ref requests that MR 3 (!256820) writes; until MR 3 ships, nothing writes them, so the new check always returns false.
MergeRequest#pipeline_creating? now also returns true when a pipeline is being created for the source ref, via a new pipeline_creating_for_source_ref?, gated on track_ref_pipeline_creation. This closes the branch-pipeline race: the CI mergeability check now blocks a merge while a ref pipeline is still being created, not only while a merge-request pipeline is being created. Alongside that mergeability change in merge_request.rb, this MR also adds the ref-lookup methods it needs on Ci::PipelineCreation::Requests: for_ref, pipeline_creating_for_ref?, and the key helpers ref_key and REF_REDIS_KEY.
This MR is safe to merge while the flag is off. To back out the merge blocking, turn the flag off.
Feature flag
track_ref_pipeline_creation (type gitlab_com_derisk, default_enabled: false), milestone 19.5, introduced_by_url points to this MR (!256821 (merged)). The rollout issue and feature issue already exist and are reused, not recreated.
No UI changes.
References
- Reinstated MR: !232296 (merged)
- Revert MR: !239194 (merged)
- Incident: gitlab-com/gl-infra/production#22243 (closed)
- Feature issue: #595420
- Rollout issue: #597220
- Part 2 of 3 in this stack: MR 1 (scaffolding, !256819 (merged)), MR 2 (mergeability, this MR, !256821 (merged)), MR 3 (writer, feature-flagged, !256820)