Repository navigation
fix(python): budget health probes against the startup deadline - #3009
Merged
Merged
Conversation
The readiness wait checked the deadline only after a failed probe, and every probe used a fixed 5-second HTTP timeout. A `/health` response that arrived after `startup_timeout` had expired was accepted as ready, and a read, write or pool timeout from a probe escaped `start()` as a raw httpx exception instead of being retried like a connect timeout. Limit each probe and each back-off sleep to the remaining budget, accept a probe result only while budget remains, and treat every httpx timeout as "still starting".
Closed
2 tasks done
…adline # Conflicts: # python/src/mlxcel/_server.py
test_startup_replaces_a_socket_nobody_listens_on (from lablup#3017) failed in about one run in two on a loaded macOS host with "did not become ready within 2s": a freshly written stand-in executable can take seconds to launch there (XProtect scans it on first exec), and the 2 s budget killed the child before it recorded that it bound the path. The stand-ins exit on their own well before the budget, so raising it to 10 s costs no time on a healthy run. Validation: five consecutive full runs of pytest python/tests -m "not e2e" on Python 3.9 on the same host (128 passed each, previously 3 of 5 failed), plus Python 3.11, ruff check, ruff format --check. Refs lablup#3008
Member
|
Thanks for this. Reviewed against #3008: each probe's HTTP timeout is capped by the remaining budget, a 200 that lands after the deadline raises Changes on the branch:
Locally on macOS: 128 passed, 2 deselected on Python 3.11 and in five consecutive Python 3.9 runs; ruff and mypy clean. The |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Python client's readiness wait could return "ready" after
startup_timeouthad already expired, because the deadline was checked only after a failed probe and every probe ran with a fixed 5-second HTTP timeout. Probes are now limited to the time that is left, a 200 that arrives after the deadline is not accepted, and probe timeouts of every kind are retried until the deadline.Related issues
Closes #3008.
Type of change
fix— bug fixCause
_wait_until_ready(python/src/mlxcel/_server.py) returned as soon as_probe_oncereported 200 and compared the clock with the deadline only otherwise. The probe client's timeout was a constant 5.0 s._probe_oncecaughtConnectError,ConnectTimeoutandReadError;ReadTimeout,WriteTimeoutandPoolTimeoutescapedstart()as rawhttpxexceptions.Change
timeout=min(5.0, remaining), and the back-off sleep is capped by the remaining budget as well.MlxcelTimeoutErroris raised as before, with the existing cleanup of the child._probe_oncetreatshttpx.TimeoutException(the base of all four timeout types) as "still starting".python/tests/test_lifecycle.py:test_health_probe_timeout_is_retryable(four timeout types),test_slow_health_cannot_succeed_after_startup_deadline, and the controltest_slow_health_within_startup_budget_is_ready.python/tests/fake_server.pygains a--health-delayoption for them.Before / after
Linux aarch64, Python 3.12.3, a fake server on loopback whose
/healthanswers after a delay.mainstartup_timeout=0.2, health delay 1.0 sMlxcelTimeoutErrorafter 0.205 s, child exitedstartup_timeout=3.0, health delay 0.05 s (control)ConnectTimeoutand the within-budget control)-m "not e2e"), openai 3.49.0 / httpx 0.28.1Test plan
Run on this PR's source (one commit on
955335a38, tree7ebead15b346).python -m pytest -m "not e2e"inpython/: 57 passed, 2 deselected, with the declared lower bounds and with current releasesmain: 4 failed, 2 passedruff check python,ruff format --check python,mypy python/src: passNotes for reviewers
startup_timeoutis documented to mean, but it is stricter thanmain.httpxtimeouts apply per phase (connect, read, write, pool), so the bound is not a hard wall-clock guarantee; the 0.205 s above is one measurement of a delayed response header. Only the readiness wait changes: request timeouts and API error handling are untouched.Checklist
docs/: not needed// Used by: ...comments: not applicable (Python).envfiles committed