TestDockerCommandWithDoingPruneAndAfterScript can fail with exit code 1 (suspected container-exit race)
Summary
TestDockerCommandWithDoingPruneAndAfterScript in
executors/docker/docker_command_integration_test.go failed with exit code 1 (observed on an unrelated MR:
https://gitlab.com/gitlab-org/gitlab-runner/-/jobs/15212124101, job
integration test with race 3/4).
Location
successfulBuild.Steps[0].Script = spec.StepScript{
"docker ps -a -f status=exited | grep runner-doprune-",
"docker rm $(docker ps -a -f status=exited | grep runner-doprune- | awk '{print $1}')",
}Suspected root cause
This script checks (via docker ps -a -f status=exited | grep runner-doprune-) that a previously-run runner-doprune-* container has
already transitioned to the Exited state, then removes it. If that
transition hasn't completed by the time this later script step runs,
grep finds no matches and exits 1, failing the whole job — even though
no real regression occurred. This looks like a race between container
state transition and the check script, not a hard/reproducible failure;
I don't have confirmed evidence of the exact trigger or how often this
reproduces.
Impact
Intermittent test failure, currently unquantified frequency, in a docker-executor integration test.
Suggested fix
Retry/poll for the exited container for a short period instead of a single one-shot check, to tolerate the state-transition race.