Poll for exited container in prune integration test
Summary
TestDockerCommandWithDoingPruneAndAfterScript checked, in a single
one-shot grep, whether an earlier build stage's runner-doprune-*
container had already transitioned to the exited state. Observed
failing with exit code 1 in CI on an unrelated MR:
https://gitlab.com/gitlab-org/gitlab-runner/-/jobs/15212124101
Note: the exact trigger isn't confirmed — I don't have evidence this reproduces reliably, only a single observed failure. The fix below is a best-effort mitigation for the most likely cause (a race between the container's state transition and this check), not a confirmed root-cause fix.
Suspected cause
The container's transition to exited isn't necessarily visible via
the shared docker socket the instant the earlier build stage's
container stops, so a single immediate check can race with that
transition.
Fix
Poll for up to 10 seconds instead of checking once, while still failing the job if the container is genuinely never found — preserving the test's original intent (it should still fail if prune functionality doesn't work).
Verification
go build/go vetclean,golangci-lint0 issues.- Verified the retry-loop shell logic directly under
alpine:latest'sshfor both the "found on a later attempt" and "never found" cases — the latter still exits 1 as before. - Could not reproduce the original race directly (it depends on runner-host timing), so this MR should be watched for whether the failure recurs after merge.
Closes #39591 (closed)