Skip to content

Conversation

@messiaen
Copy link
Contributor

@messiaen messiaen commented Jul 10, 2025

Overview:

Add /live endpoint

Add environment variables to set http paths. useful if we need to move health or metrics to conform with existing schemas. move /health to /v1/health/ready for example

Details:

Where should the reviewer start?

health.rs

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

  • closes GitHub issue: #xxx

Summary by CodeRabbit

  • New Features
    • Introduced new health check endpoints for service liveness and readiness, accessible at /v1/health/live and /v1/health/ready.
    • The liveness endpoint returns a fixed JSON response indicating the service is operational.
    • The readiness endpoint reports service health based on model endpoint availability.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 10, 2025

Walkthrough

New liveness and readiness HTTP health check routers were introduced, each with their own endpoints and handlers. The liveness router returns a static JSON indicating the service is live, while the readiness router reuses the existing health handler. These routers are now registered in the service's route initialization.

Changes

Files / Areas Changed Summary
lib/llm/src/http/service/health.rs Added live_check_router and ready_check_router functions, a new live_handler, and renamed a local variable in health_check_router for clarity.
lib/llm/src/http/service/service_v2.rs Registered the new liveness and readiness routers in the HTTP service configuration builder.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Router
    participant ServiceState

    Client->>Router: GET /v1/health/live
    Router->>ServiceState: (extract state, unused)
    Router-->>Client: 200 OK {"status":"live"}

    Client->>Router: GET /v1/health/ready
    Router->>ServiceState: Check model endpoint availability
    Router-->>Client: 200 OK {"status":"ready"} or 503 Service Unavailable
Loading

Poem

In the warren of code, new paths appear,
Liveness and readiness, now crystal clear.
A hop to "live," a skip to "ready,"
Health checks abound, responses steady.
With routers aligned and endpoints anew,
This rabbit applauds the work you do!
🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7bc70bc and 690ebb5.

📒 Files selected for processing (2)
  • lib/llm/src/http/service/health.rs (1 hunks)
  • lib/llm/src/http/service/service_v2.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
lib/llm/src/http/service/service_v2.rs (2)
Learnt from: alec-flowers
PR: ai-dynamo/dynamo#1181
File: lib/llm/src/kv_router/publisher.rs:379-425
Timestamp: 2025-05-29T00:02:35.018Z
Learning: In lib/llm/src/kv_router/publisher.rs, the functions `create_stored_blocks` and `create_stored_block_from_parts` are correctly implemented and not problematic duplications of existing functionality elsewhere in the codebase.
Learnt from: PeaBrane
PR: ai-dynamo/dynamo#1285
File: lib/llm/src/kv_router/scoring.rs:58-63
Timestamp: 2025-05-30T06:38:09.630Z
Learning: In lib/llm/src/kv_router/scoring.rs, the user prefers to keep the panic behavior when calculating load_avg and variance with empty endpoints rather than adding guards for division by zero. They want the code to fail fast on this error condition.
lib/llm/src/http/service/health.rs (3)
Learnt from: alec-flowers
PR: ai-dynamo/dynamo#1181
File: lib/llm/src/kv_router/publisher.rs:379-425
Timestamp: 2025-05-29T00:02:35.018Z
Learning: In lib/llm/src/kv_router/publisher.rs, the functions `create_stored_blocks` and `create_stored_block_from_parts` are correctly implemented and not problematic duplications of existing functionality elsewhere in the codebase.
Learnt from: PeaBrane
PR: ai-dynamo/dynamo#1285
File: lib/llm/src/kv_router/scoring.rs:58-63
Timestamp: 2025-05-30T06:38:09.630Z
Learning: In lib/llm/src/kv_router/scoring.rs, the user prefers to keep the panic behavior when calculating load_avg and variance with empty endpoints rather than adding guards for division by zero. They want the code to fail fast on this error condition.
Learnt from: PeaBrane
PR: ai-dynamo/dynamo#1392
File: lib/llm/src/kv_router/scoring.rs:35-46
Timestamp: 2025-06-05T01:02:15.318Z
Learning: In lib/llm/src/kv_router/scoring.rs, PeaBrane prefers panic-based early failure over Result-based error handling for the worker_id() method to catch invalid data early during development.
🧬 Code Graph Analysis (2)
lib/llm/src/http/service/service_v2.rs (1)
lib/llm/src/http/service/health.rs (2)
  • live_check_router (51-64)
  • ready_check_router (66-79)
lib/llm/src/http/service/health.rs (2)
lib/llm/src/http/service.rs (1)
  • new (45-50)
lib/llm/src/http/service/metrics.rs (1)
  • router (465-473)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Mirror Repository to GitLab
  • GitHub Check: pre-merge-rust (lib/runtime/examples)
  • GitHub Check: pre-merge-rust (lib/bindings/python)
  • GitHub Check: pre-merge-rust (.)
  • GitHub Check: Build and Test - vllm
🔇 Additional comments (5)
lib/llm/src/http/service/service_v2.rs (1)

154-155: LGTM! Health routers properly integrated.

The new liveness and readiness check routers are correctly added to the routes vector, following the established pattern of the existing health check router. The integration maintains consistency with the existing codebase structure.

lib/llm/src/http/service/health.rs (4)

40-40: Good variable rename for clarity.

Renaming the variable from path to health_path improves code readability and makes the intent clearer, especially now that multiple path variables exist in the same file.

Also applies to: 42-42, 45-45


51-64: Liveness router implementation looks correct.

The live_check_router function follows the established pattern and correctly implements a Kubernetes liveness probe endpoint. The default path /v1/health/live follows K8s conventions.


66-79: Readiness router appropriately reuses health logic.

The ready_check_router function correctly reuses the existing health_handler for readiness checks, which is appropriate since readiness should verify that the service can handle traffic (i.e., has available model endpoints).


81-91: Live handler implementation follows K8s best practices.

The live_handler correctly returns a static JSON response indicating the service is live, which is appropriate for Kubernetes liveness probes. The unused state parameter is properly prefixed with underscore, and the HTTP 200 status code is correct for a healthy liveness check.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@messiaen messiaen force-pushed the grclark/health-endpoints branch from 120f10b to 46e7a53 Compare July 10, 2025 03:44
@messiaen messiaen changed the title chore: add live and ready health endpoints for k8s chore: envvars for http paths and live health endpoint Jul 10, 2025
@messiaen messiaen enabled auto-merge (squash) July 14, 2025 15:57
@messiaen messiaen merged commit c708041 into main Jul 14, 2025
11 of 12 checks passed
@messiaen messiaen deleted the grclark/health-endpoints branch July 14, 2025 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants