WIP: Make sure head pippeline always corresponds with an MR

Open Jarka Kadlecova requested to merge 37354-pipelines-update into master


  • need to check the case described in the issue comments

What does this MR do?

It does not update the head_pipeline of merge requests directly from Ci::CreatePipelineService but enqueues the update instead.

Are there points in the code the reviewer needs to double check?

Error handling in the worker

Why was this MR needed?

As described in the issue it can happen that the head pipeline of a merge request is set to the pipeline that is actually not the pipeline that should be associated to the merge request.

This can happen due to the following workflow:

  1. a user pushes a change
  2. GitPushService is called - from this service
  • UpdateMergeRequestsWorker job is enqueued
  • Ci::CreatePipelineService is executed
  1. inside Ci::CreatePipelineService
  • a new pipeline is created
  • head_pipeline_id of all merge requests that have the same source_project and source_branch as the created pipeline are updated to the id of the created pipeline
  1. head_pipeline can be updated before a merge request is refreshed from UpdateMergeRequestsWorker -> the merge request still references an old sha but associated pipeline already a new sha

Screenshots (if relevant)

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Closes #37354