Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a built-in per-application health check endpoint GET {route_prefix}/-/healthz (when the route prefix is not /) that calls the ingress deployment's check_health method on a running replica. This health check bypasses request admission and does not consume a max_ongoing_requests slot, allowing saturated deployments to still respond to health probes. The feedback recommends distributing the health check load across replicas using random.choice instead of always querying the first replica to prevent hot-spotting. Additionally, it is suggested to log exception tracebacks with exc_info=True when health checks fail in both the proxy and replica to improve observability.
| replicas = list(self._active_request_router.curr_replicas.values()) | ||
| if not replicas: | ||
| raise DeploymentUnavailableError(self.deployment_id) | ||
|
|
||
| await replicas[0].check_health() |
There was a problem hiding this comment.
Always querying the first replica (replicas[0]) for the application health check can lead to hot-spotting, where a single replica bears the entire load of health check requests from external load balancers. Additionally, if that specific replica is experiencing local issues or is slow, the entire application might be incorrectly marked as unhealthy. Using random.choice distributes the health check load and provides a more representative sample of the application's overall health.
import random
replicas = list(self._active_request_router.curr_replicas.values())
if not replicas:
raise DeploymentUnavailableError(self.deployment_id)
await random.choice(replicas).check_health()There was a problem hiding this comment.
leaving the first replica. this probe does not take a request slot, so it is not request load. random.choice still checks only one replica, and the controller already health checks every replica.
| except Exception: | ||
| logger.warning( | ||
| "Application health check failed.", | ||
| extra={"log_to_stderr": False}, | ||
| ) |
There was a problem hiding this comment.
When the application health check fails, logging the exception traceback with exc_info=True is highly recommended. This provides critical context (such as connection timeouts, database errors, or internal bugs) to help operators diagnose why the health check failed.
| except Exception: | |
| logger.warning( | |
| "Application health check failed.", | |
| extra={"log_to_stderr": False}, | |
| ) | |
| except Exception: | |
| logger.warning( | |
| "Application health check failed.", | |
| exc_info=True, | |
| extra={"log_to_stderr": False}, | |
| ) |
There was a problem hiding this comment.
the traceback is now included.
| except Exception: | ||
| logger.warning("Application health check failed.") | ||
| healthy = False | ||
| message = "UNHEALTHY" |
There was a problem hiding this comment.
Logging the exception traceback with exc_info=True when the replica's health check fails will greatly improve observability and make debugging much easier for operators.
| except Exception: | |
| logger.warning("Application health check failed.") | |
| healthy = False | |
| message = "UNHEALTHY" | |
| except Exception: | |
| logger.warning("Application health check failed.", exc_info=True) | |
| healthy = False | |
| message = "UNHEALTHY" |
There was a problem hiding this comment.
the traceback is now included.
fe5b1cb to
59569ab
Compare
49e40c0 to
4bd27ff
Compare
4bd27ff to
a2395ed
Compare
Applications with a non-root route prefix can probe
{route_prefix}/-/healthz. That path calls ingress check_health and does
not take a max_ongoing_requests slot. System /-/healthz and ordinary
application routes are unchanged.
Closes ray-project#66509
Signed-off-by: Dundy Pasupuleti <[email protected]>
a2395ed to
dc9f15b
Compare
|
@abrarsheikh @edoakes gentle ping for review when you get a chance; this is the per-app |
|
left a question #66509 (comment) |
Per the discussion on ray-project#66509, the per-app health route now reports the application status Serve already tracks (200 when RUNNING, 503 otherwise) instead of calling check_health on an ingress replica. The controller pushes {app name: status} to the proxies over a new APPLICATION_STATUSES long poll key, and the proxy answers the route from that without routing to a replica. Drops the replica-side check_health path and its retry/timeout handling. Signed-off-by: Dundy Pasupuleti <[email protected]>
|
@abrarsheikh reworked this to follow (a) per the thread on #66509: |
| message = HEALTHY_MESSAGE | ||
| else: | ||
| healthy = False | ||
| message = status.value if status is not None else "UNKNOWN" |
There was a problem hiding this comment.
Probes fail during rolling updates
High Severity
{route_prefix}/-/healthz is healthy only when application status is RUNNING, so it returns 503 for DEPLOYING. A config update puts deployments in UPDATING and the app back into DEPLOYING even while old replicas still serve. Load-balancer and Kubernetes probes pointed at this path then fail for the whole rollout and can take serving backends out of rotation.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 3dc61c3. Configure here.
There was a problem hiding this comment.
good catch. fixed in 7cc7f23: the proxy now remembers apps that reached RUNNING, so a config update (RUNNING back to DEPLOYING while old replicas serve) keeps {route_prefix}/-/healthz at 200. a first deploy, DEPLOY_FAILED, UNHEALTHY and DELETING still return 503, and DELETING resets it. added a unit test for the update path and updated the docs.
A config update moves a RUNNING app back to DEPLOYING while its existing replicas keep serving, so reporting 503 for every DEPLOYING app would fail probes for the whole rollout. The proxy now remembers which apps reached RUNNING and answers 200 for those while they are DEPLOYING. A first deploy, DEPLOY_FAILED, UNHEALTHY, and DELETING still report 503. Also fixes import order flagged by the ruff isort hook. Signed-off-by: Dundy Pasupuleti <[email protected]>
The proxy used to remember which apps had reached RUNNING to keep
{route_prefix}/-/healthz at 200 during an in-place update. A proxy that
starts or restarts mid-update never saw RUNNING, so it returned 503 while
the old replicas were still serving.
The controller now broadcasts (status, serving) per app, where serving is
RUNNING, or DEPLOYING while the ingress deployment has running replicas.
It is derived from live replica state, so every proxy agrees and nothing
is lost on a proxy restart.
Signed-off-by: Dundy Pasupuleti <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
Reviewed by Cursor Bugbot for commit 94ca62c. Configure here.
A declarative rebuild clears the app's target ingress until the build
task finishes, while the old deployments keep serving. The controller
treated a missing ingress as not serving, so {route_prefix}/-/healthz
returned 503 for a healthy app during the build.
Fall back to the endpoint the proxies are still routing the app to
when the target ingress is unset. A first deploy has no endpoint yet
and still reports not serving.
Also fix the mypy union-attr error on the status message in the proxy.
Signed-off-by: Dundy Pasupuleti <[email protected]>
|
hi @abrarsheikh, i addressed the bugbot points and the probe timeout. the remaining microcheck failure was an npm 504 during a lint job, so it may just need a rerun. could you take another look? |
|
fyi the red microcheck is |
…blocks (#67432) ## Description Converts the last `>>>` doctest examples on documentation pages, so `>>>` examples remain only in docstrings and on the two pages that teach the docstring format. #67429 changes the contributor guidance to match. This PR is independent of that stack and targets `master`. Before this PR, seven pages under `doc/source/` had `>>>` prompts. Two of them teach the docstring format and stay as they are: `ray-contribute/writing-code-snippets.md` and `ray-contribute/getting-involved.md`. This PR converts the other five: | Page | Before | After | Test coverage | |---|---|---|---| | `data/working-with-tensors.md` | Three `{doctest}` blocks | `{testcode}` and `{testoutput}` blocks | Unchanged. The `dtype` and shape checks still run. The two per-image shapes the doctest skipped are now a `+MOCK` sample. | | `ray-references/glossary.md` | One `{doctest}` block with `+SKIP` on every line | `{testcode}` and `{testoutput}` | Gained. The block used to run nothing and now runs. The expected output is unchanged, because Ray produces it exactly. | | `serve/advanced-guides/multi-app-container.md` | `>>>` prompts in a `python` fence, with every request skipped | Plain `python` and `text` blocks | None before or after. The requests need the containerized Serve apps running. The doctest only ran `import requests` and two string assignments. | | `core/tasks/nested-tasks.md` | REPL transcript in a `bash` block | Plain `python` and `text` blocks | None before or after. The page's `doc_code/` script is tested. | | `serve/production-guide/fault-tolerance.md` | Interactive `$ python` / `>>>` transcripts | Plain `python` blocks, with `text` blocks for output | None before or after. These steps kill actors on a live cluster. | ### Test wiring - `doc/BUILD.bazel`: - Removes the Serve `doctest_each` call. Its only file was `multi-app-container.md`, which no longer has a runnable example, so the target would pass without testing anything. - Drops the comment explaining why `nested-tasks.md` isn't listed, since the page no longer has anything runnable to explain. - The glossary and tensors entries stay, because both pages still have runnable examples. - `doc/test_prose_doctest_targets.py`: removes `nested-tasks.md` and `fault-tolerance.md` from `UNTESTED`. Neither page has a runnable example now. The two docstring-teaching pages stay exempt. No `.buildkite/test.rules.txt` change. All prose routes to `doc_example` whether or not a doctest target names the page, and the existing routing cases for these pages still hold. This PR edits `doc/BUILD.bazel`, so premerge runs every library's docs example step. The glossary target is tagged `team:none`, which runs only post-merge or with `docs-example-test`, so this PR carries that label too. ## Related issues Companion to #67429, which reserves `>>>` doctest-style examples for docstrings in the contributor guide. ## Additional information ### Duplicate check I searched open PRs for each converted page and for `doctest` in titles. #66705 edits `fault-tolerance.md` around line 53, far from these hunks. Draft #66851 appends a line to `nested-tasks.md` after these hunks. Neither converts these examples. The docstring conversion PRs (#67238, #66745, #67237) touch `python/`, not pages. ### Testing I reproduced the CI doctest runner locally: Ray 2.59.0, Python 3.11, `pytest==7.4.4`, `ray-project/pytest-sphinx@c1ab2b33`, the Ray Data `doctest_pytest_plugin.py`, and the macro's `--doctest-modules --doctest-glob='*.md' -c NO_PYTEST_CONFIG` arguments. - `working-with-tensors.md`: passes before (2 items: the doctest blocks and the testcode blocks) and after (1 item). A copy with a wrong expected shape fails with `Expected (32, 28, 99) / Got (32, 28, 28)`, so the new assertions are live. - `glossary.md`: before, 1 skipped. After, 1 passed. A copy with a wrong expected value fails. - `python doc/test_prose_doctest_targets.py`: "73 listed pages; every runnable page is accounted for." - `pre-commit run --files` on the changed files passes, including buildifier and buildifier-lint. - `vale` on each changed page: no new alerts compared with `master`. - After this PR, `git grep -l '^\s*>>> '` over `doc/source/*.md` and `*.rst` returns only the two pages that teach the docstring format. - The Read the Docs preview covers rendering. This PR was prepared with AI assistance (Claude Code). I reviewed every changed line. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
…h-66509 Signed-off-by: Dundy Pasupuleti <[email protected]> # Conflicts: # python/ray/serve/tests/unit/test_controller.py
|
@eicherseiji could you take a look when you have time? this answers {route_prefix}/-/healthz from the app status serve already tracks, per the direction on #66509; ci is green on 255820a |
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |


Summary
Application routes, including a user-defined
/healthz, take a replica slot in_start_request. Only system/-/healthzskips admission. Whenmax_ongoing_requestsis saturated, a probe that reads app status through the ingress waits for a slot even though the app is fine, and a supervisor restarts a process that was only busy.Following option (a) from the discussion on #66509, this adds
GET {route_prefix}/-/healthzfor a non-root route prefix and answers it from the application status Serve already tracks:200when the application isRUNNING503otherwise, with the status in the body (DEPLOYING,UNHEALTHY,DEPLOY_FAILED,DELETING, orUNKNOWNbefore the proxy has received statuses)503while the proxy is drainingThe request is never routed to a replica, so it does not call
check_healthand does not take amax_ongoing_requestsslot. The controller pushes{app name: status}to the proxies over a newAPPLICATION_STATUSESlong poll key, only when it changes, so a probe adds no controller calls.System
/-/healthzis unchanged (proxy readiness). Ordinary application routes still count toward the limit. A route prefix of/has no separate path, because/-/healthzis already the system route.The earlier revision called the ingress
check_healthon one replica; that path, and its retry/timeout handling, is removed.Fixes #66509
cc @edoakes @abrarsheikh
Test plan
300 passed locally. New tests cover RUNNING -> 200, each non-running status -> 503, unknown status -> 503, draining -> 503, no routing to a replica, system
/-/healthzunchanged, and the controller broadcasting statuses only on change. ruff and black clean.