Skip to content

fix(router): repair main build breaks and deflake client timeout test - #2238

Merged
slin1237 merged 2 commits into
mainfrom
fix/pd-empty-fleet-test-deref
Aug 20, 2026
Merged

fix(router): repair main build breaks and deflake client timeout test#2238
slin1237 merged 2 commits into
mainfrom
fix/pd-empty-fleet-test-deref

Conversation

@pallasathena92

Copy link
Copy Markdown
Collaborator

Description

Problem

main currently fails cargo test compilation and cargo clippy -D warnings, which breaks the unit-tests lane on every PR merge build. Two concurrently merged changes raced: the owned-body dispatch refactor retyped the request body as Bytes and boxed PdSelectionFailure, while another branch merged code still wrapping the body in Bytes::from(...) and matching the selection failure unboxed. Each PR was green alone; their merge is not.

Separately, worker::http_client::tests::per_request_timeout_overrides_client_default is flaky: it races a zero-duration total timeout against a loopback echo response, and the fast local 200 wins often enough to fail roughly half of runs (reproduced locally at that rate; it also failed a PR lane today).

Solution

  • Pass the already-Bytes body through directly at both dispatch sites and deref the boxed failure in the empty-fleet test — restores compile and clippy cleanliness.
  • Deflake the timeout test: the client-default leg now targets a route that sleeps far past any deadline, so the zero timeout always fires; the per-request-override leg keeps the instant route. Same contract, no race.

Changes

  • model_gateway/src/routers/http/pd_router.rs: drop redundant Bytes::from, deref boxed PdSelectionFailure in test_empty_worker_lists
  • model_gateway/src/routers/http/router.rs: drop redundant Bytes::from
  • model_gateway/src/worker/http_client.rs: add a hanging /hang route to the test echo server; aim the client-default timeout assertion at it

Test Plan

  • cargo clippy -p smg --all-targets -- -D warnings passes (was 4 errors)
  • cargo test -p smg --lib passes: 1789 passed, 0 failed (compilation was broken before)
  • per_request_timeout_overrides_client_default passes 10/10 consecutive runs (previously ~half failed)
  • cargo test -p smg --test inflight_tracker_test --test routing_tests passes (132 tests, closest integration coverage to the dispatch sites)
  • cargo +nightly fmt clean
Checklist
  • cargo +nightly fmt passes
  • cargo clippy --all-targets -- -D warnings passes for the touched crate
  • (Optional) Documentation updated
  • (Optional) Please join us on Slack #sig-smg to discuss, review, and merge PRs

Two concurrently merged changes raced: the owned-body dispatch change
retyped the request body as Bytes while another branch still wrapped it
in Bytes::from and matched an unboxed selection failure. The merged
result fails cargo test compilation (E0308 on the boxed
PdSelectionFailure) and clippy (useless_conversion behind an
unused_qualifications shadow), breaking every PR merge build.

Pass the already-Bytes body through directly and deref the boxed
failure in the empty-fleet test.

Signed-off-by: Simo Lin <25425177+slin1237@users.noreply.github.com>
per_request_timeout_overrides_client_default raced a zero-duration
total timeout against a loopback echo response; the fast 200 wins often
enough to fail roughly half of local runs. Point the client-default leg
at a route that sleeps far past any deadline so the timeout always
fires, keeping the per-request override leg on the instant route.

Signed-off-by: Simo Lin <25425177+slin1237@users.noreply.github.com>
@github-actions github-actions Bot added the model-gateway Model gateway crate changes label Aug 20, 2026
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 67b3a129-7957-4009-8f1d-2c5d861e9af9

📥 Commits

Reviewing files that changed from the base of the PR and between 4ff7d6e and 094527c.

📒 Files selected for processing (3)
  • model_gateway/src/routers/http/pd_router.rs
  • model_gateway/src/routers/http/router.rs
  • model_gateway/src/worker/http_client.rs

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of HTTP request bodies for more reliable request processing.
    • Corrected empty-worker error handling in internal request selection.
    • Strengthened timeout behavior validation for requests with client-level and per-request timeout settings.

Walkthrough

The HTTP routers now forward existing Bytes bodies without conversion. The selection failure test matches the boxed value correctly. The HTTP client timeout test uses a hanging endpoint to verify client-level and per-request timeout behavior.

Changes

HTTP request handling

Layer / File(s) Summary
Direct request body forwarding
model_gateway/src/routers/http/pd_router.rs, model_gateway/src/routers/http/router.rs
The routers pass existing Bytes request bodies directly. The selection failure test dereferences the boxed failure before matching.
Timeout test behavior
model_gateway/src/worker/http_client.rs
The test server adds a /hang endpoint. The timeout test uses /hang for the client default timeout and retains /probe for the per-request override.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: catherinesue, key4ng

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pd-empty-fleet-test-deref

Comment @coderabbitai help to get the list of available commands.

@slin1237
slin1237 merged commit 322f5bc into main Aug 20, 2026
9 of 14 checks passed
@slin1237
slin1237 deleted the fix/pd-empty-fleet-test-deref branch August 20, 2026 18:07

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean post-merge fixup. All three changes are correct: redundant Bytes::from() removal matches the already-Bytes parameter types, the box deref aligns with the boxed PdSelectionFailure return type, and the hanging-route deflake soundly eliminates the timer race. No issues found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

model-gateway Model gateway crate changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants