Skip to content

Commit a724f5b

Browse files
parametric: fail fast when test client container exits during startup wait (#7324)
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 8faf8fe commit a724f5b

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

  • utils/docker_fixtures/_test_clients

utils/docker_fixtures/_test_clients/_core.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,19 @@ def _wait(self, timeout: float):
169169
try:
170170
if self._is_alive():
171171
break
172-
except Exception:
173-
if self.container.status != "running":
174-
self._print_logs()
175-
message = f"Container {self.container.name} status is {self.container.status}. Please check logs."
176-
_fail(message)
172+
except Exception as e:
173+
logger.debug(f"Error while checking if {self.container.name} is alive: {e}")
174+
175+
# _is_alive() swallows a non-running container status and returns False instead of
176+
# raising, so the check must be repeated here on every iteration (not only in the
177+
# except branch above) or a container that exits early (e.g. crash, port collision)
178+
# silently gets retried for the full timeout instead of failing fast with its logs.
179+
self.container.reload()
180+
if self.container.status not in ("running", "created"):
181+
self._print_logs()
182+
message = f"Container {self.container.name} status is {self.container.status}. Please check logs."
183+
_fail(message)
184+
177185
time.sleep(delay)
178186
else:
179187
self._print_logs()

0 commit comments

Comments
 (0)