fix(lease-broker): wait_ready() polls real connect-readiness not socket-file existence (flaky CI race) #898

Merged
Mos merged 1 commits from fix/recovery-b1-wait-ready-race into main 2026-07-25 22:10:15 +00:00

1 Commits

Author SHA1 Message Date
mosaic-coder
98a20bfaab fix(lease-broker): wait_ready() polls real connect-readiness not socket-file existence (flaky CI race)
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
setUp() spawned the daemon and polled only for the unix-socket file to
exist before proceeding to connect(). Under concurrent CI-runner load
the socket file can appear (created by bind()) before the daemon calls
listen(), so the client's immediate connect() raced ahead and hit
ConnectionRefusedError: [Errno 111], erroring the whole suite in
setUp().

wait_ready() now attempts a real socket.connect() in a retry loop
(catching ConnectionRefusedError/FileNotFoundError) until a connection
actually succeeds (then closes it) or the same 5s deadline elapses,
at which point it fails exactly as before. Readiness is now "the
daemon is actually accepting connections," not "a file happens to
exist," eliminating the TOCTOU race.

Scope: only wait_ready() in this file changed. Zero assertion changes,
zero daemon/lease-broker source changes, zero gate-timeout relaxation.

Closes #897
2026-07-25 16:47:42 -05:00