fix(lease-broker): wait_ready() polls real connect-readiness not socket-file existence (flaky CI race) (#898)
Co-authored-by: jason.woltje <jason@diversecanvas.com> Co-committed-by: jason.woltje <jason@diversecanvas.com>
This commit was merged in pull request #898.
This commit is contained in:
@@ -51,8 +51,13 @@ def request(socket_path: Path, value: dict[str, object]) -> dict[str, object]:
|
|||||||
def wait_ready(process: subprocess.Popen[str], socket_path: Path) -> None:
|
def wait_ready(process: subprocess.Popen[str], socket_path: Path) -> None:
|
||||||
deadline = time.monotonic() + 5.0
|
deadline = time.monotonic() + 5.0
|
||||||
while time.monotonic() < deadline:
|
while time.monotonic() < deadline:
|
||||||
if socket_path.exists():
|
try:
|
||||||
|
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as probe:
|
||||||
|
probe.settimeout(0.25)
|
||||||
|
probe.connect(str(socket_path))
|
||||||
return
|
return
|
||||||
|
except (ConnectionRefusedError, FileNotFoundError):
|
||||||
|
pass
|
||||||
if process.poll() is not None:
|
if process.poll() is not None:
|
||||||
output = process.stdout.read() if process.stdout is not None else ""
|
output = process.stdout.read() if process.stdout is not None else ""
|
||||||
raise RuntimeError(f"daemon exited before READY: {output}")
|
raise RuntimeError(f"daemon exited before READY: {output}")
|
||||||
|
|||||||
Reference in New Issue
Block a user