Skip to content

The agent that grows with you

test(docker): a stalled docker exec is one failed poll attempt, not the verdict

Tekniumccb3f388f7ea
diff --git a/tests/docker/conftest.py b/tests/docker/conftest.py
index 6597c068121..79817e698da 100644
--- a/tests/docker/conftest.py
+++ b/tests/docker/conftest.py
@@ -242,7 +242,12 @@ def poll_container(
end = time.monotonic() + deadline_s
last = ""
while time.monotonic() < end:
- r = docker_exec_sh(container, probe, user=user, timeout=10)
+ try:
+ r = docker_exec_sh(container, probe, user=user, timeout=10)
+ except subprocess.TimeoutExpired:
+ # A stalled ``docker exec`` (busy daemon on a loaded runner) is one failed attempt,
+ # not the verdict: keep polling until the deadline like any other non-zero probe.
+ continue
last = r.stdout
if r.returncode == 0:
return True, last
diff --git a/tests/docker/test_dashboard.py b/tests/docker/test_dashboard.py
index 7a7b762136d..ce59de958d8 100644
--- a/tests/docker/test_dashboard.py
+++ b/tests/docker/test_dashboard.py
@@ -13,6 +13,7 @@ the realistic runtime context. See the conftest module docstring.
from __future__ import annotations
import json
+import subprocess
import time
from tests.docker.conftest import docker_exec, docker_exec_sh, start_container, poll_container
@@ -97,7 +98,11 @@ except urllib.error.HTTPError as h:
end = time.monotonic() + deadline_s
last_err = ""
while time.monotonic() < end:
- r = docker_exec_sh(container, probe, timeout=10)
+ try:
+ r = docker_exec_sh(container, probe, timeout=10)
+ except subprocess.TimeoutExpired as exc:
+ last_err = f"docker exec stalled: {exc}" # a busy daemon: retry until the deadline
+ continue
if r.returncode == 0 and r.stdout.strip():
lines = r.stdout.split("\n", 1)
try: