Skip to content

Fix potential race condition in Docker provider test

Stan Hu requested to merge sh-fix-race-condition into main

What does this MR do?

As seen in https://gitlab.com/gitlab-org/gitlab-runner/-/jobs/4717853511, there is a potential data race between reading list in the test. This can happen even though the test has a WaitGroup that ensures all its Goroutines have completed. However, in machineProvider create(), coordinator.waitForGrowthCapacity is launched in a separate Goroutine, which may still be running after the test's Goroutines have completed.

To fix this data race, lock the mutex in the test before reading the value of list.

Edited by Stan Hu

Merge request reports