Move job runner manager assignment to state machine

What does this MR do and why?

This MR moves the job runner manager assignment from the service layer into the state machine transition, ensuring it happens atomically when the build transitions to the running state.

Previously, the runner manager was assigned after the build.run! call in Ci::RegisterJobService#assign_job_to_running_state. By moving this assignment into the after_transition any => [:running] hook in the state machine, we ensure that:

  1. The runner manager assignment happens as part of the state transition
  2. The assignment is protected by the state machine's transaction handling
  3. Race conditions are prevented when multiple runner managers compete for the same job

The implementation uses transition.args.first to safely access the runner_manager parameter passed to the run! method, maintaining data consistency throughout the transition.

References

Closes #583083

Screenshots or screen recordings

n/a

How to set up and validate locally

n/a

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Pedro Pombeiro

Merge request reports

Loading