Skip to content

Conversation

@PeaBrane
Copy link
Contributor

@PeaBrane PeaBrane commented Jul 23, 2025

Overview:

as titled

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling in the scheduler to better manage cases where no endpoints are available, ensuring the scheduler waits for updates instead of exiting unexpectedly.
    • Increased the log severity for failed KV event transmissions from debug to warning, making such issues more visible.
  • Tests

    • Added a comprehensive end-to-end test covering concurrent streaming chat completion requests with multiple mocker engine instances and the KV router.
    • Introduced supporting test utilities and process management for reliable test orchestration.
  • Chores

    • Added license header to a new test directory file for compliance.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 23, 2025

Walkthrough

The changes introduce improved error handling and logging in the KV router's Rust code, specifically for scheduler errors and event dispatch failures. Additionally, new Python end-to-end tests are added to validate the KV router's integration with mock engine instances, including process management and concurrent streaming request verification.

Changes

File(s) Change Summary
lib/llm/src/kv_router.rs Raised log level for KV event send failures from debug to warn; no logic changes.
lib/llm/src/kv_router/scheduler.rs Added explicit handling for NoEndpoints error: logs at trace level, waits for endpoint updates, and retries.
tests/router/init.py New file with only the Apache 2.0 license header; no functional code.
tests/router/test_router_e2e_with_mockers.py New end-to-end test: launches mocker and router processes, sends concurrent streaming requests, manages cleanup.

Sequence Diagram(s)

sequenceDiagram
    participant TestRunner
    participant MockerProcess
    participant KVRouterProcess
    participant HFHub
    participant Client

    TestRunner->>HFHub: download_model()
    HFHub-->>TestRunner: (model download success/fail)
    loop For each mocker
        TestRunner->>MockerProcess: start()
    end
    TestRunner->>KVRouterProcess: start()
    loop For each concurrent request
        Client->>KVRouterProcess: POST /v1/chat/completions (streaming)
        KVRouterProcess->>MockerProcess: Forward request
        MockerProcess-->>KVRouterProcess: Streaming response
        KVRouterProcess-->>Client: Streaming response
    end
    TestRunner->>MockerProcess: terminate()
    TestRunner->>KVRouterProcess: terminate()
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~35 minutes

Poem

In the warren where routers hop and play,
New logs warn when things go astray.
Mockers gather, engines hum,
Streaming chats to everyone.
With tests that run both night and day,
The code grows stronger, come what may!
🐇✨

Note

⚡️ Unit Test Generation - Beta

CodeRabbit's unit test generation is now available in Beta! Automatically generate comprehensive unit tests for your code changes, ensuring better test coverage and catching edge cases you might miss. Our AI analyzes your code structure and creates tests that follow best practices and your project's testing patterns. Learn more here, or just try it under ✨ Finishing Touches.


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.

Signed-off-by: Yan Ru Pei <yanrpei@gmail.com>
@PeaBrane PeaBrane enabled auto-merge (squash) July 24, 2025 07:28
@PeaBrane PeaBrane merged commit ba3ac23 into main Jul 24, 2025
11 of 12 checks passed
@PeaBrane PeaBrane deleted the rupei/router-mocker-ci branch July 24, 2025 08:29
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