Race condition when enqueuing builds to run
Ci::PlayBuildService#play, we run two commands:
build.enqueue, followed by
build.update(current_user: ..., job_variables_attributes: ...)
I think it's theoretically possible for us to enqueue a build, which is then picked up and run without the correct user or job variables set.
Steps to reproduce
Easiest is probably to add a
sleep(120) between the enqueue and update, to aggravate the problem.
What is the current bug behavior?
Job runs without correct variables set
What is the expected correct behavior?
Job should not be enqueued until the system is ready to service it fully