Skip to content

[Bugfix][Router] Validate static service discovery list lengths - #1084

Merged
Shaoting-Feng merged 6 commits into
vllm-project:mainfrom
Alex-Wengg:fix-static-service-discovery-list-validation
Oct 6, 2026
Merged

Shaoting-Feng merged 6 commits into
vllm-project:mainfrom
Alex-Wengg:fix-static-service-discovery-list-validation

Conversation

@Alex-Wengg

Copy link
Copy Markdown
Contributor

Summary

StaticServiceDiscovery previously validated only urls against models. A mismatched model_labels list then failed with IndexError at request time, while a mismatched model_types list let the health loop return a partial unhealthy set.

This change:

  • validates every provided index-aligned list during construction and reports both list names and lengths;
  • replaces the optimizable assert with an explicit ValueError;
  • re-checks the invariant before health polling so later mutation cannot leak a partial result;
  • adds regression coverage for all three mismatches and the defensive health-check path.

FIX #1083

Validation

  • pytest -q src/tests/test_static_service_discovery.py — 12 passed
  • pytest -q src/tests — 235 passed
  • pre-commit run --files src/vllm_router/service_discovery.py src/tests/test_static_service_discovery.py — passed

  • Pre-commit checks pass.
  • Commit includes DCO sign-off.
  • PR title is classified.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the validation of index-aligned lists in StaticServiceDiscovery by introducing a helper method _validate_index_aligned_lists and calling it during initialization and health checks. It also adds corresponding unit tests. The feedback suggests wrapping individual model health checks in a try...except block to prevent a single failure from aborting the entire health check loop.

Comment thread src/vllm_router/service_discovery.py Resolved

@chrikrah chrikrah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two things in _validate_index_aligned_lists worth fixing before this merges, both measured on
6a33ae4 against 83c22bd.

models stops being validated. The loop guards every entry with if values is not None, but
models is required, and the assert it replaces caught a None. Constructing with models=None:
6a33ae4 raises TypeError: object of type 'NoneType' has no len(), 83c22bd constructs and then
get_endpoint_info raises TypeError: 'NoneType' object is not iterable. A dynamic-config reload
reaches it, since dynamic_config.py:179 passes parse_comma_separated_args(config.static_models) and
that returns None when static_models is absent. reconfigure_service_discovery also builds the new
object at :1421 before close() at :1425, so today a bad reload is rejected and the running router
survives. Hoisting the required list out of the loop covers it.

return [] reads as "all healthy" to the only caller. check_model_health:303 assigns it wholesale
into unhealthy_endpoint_hashes and get_endpoint_info:356 skips only hashes in that list. Through your
own mutation path with the dead endpoint first, 6a33ae4 quarantines it and 83c22bd leaves it
routable.

The second one is my fault. My expected behaviour on #1083 asked for "returns nothing rather than a
partial result" and "so the router does not treat an unchecked backend as healthy", and for this return
type those are contradictory. You built the first.

The tests do hold the change. Reverting only service_discovery.py to 6a33ae4 and keeping them gives
4 failed, 8 passed.

@Alex-Wengg

Copy link
Copy Markdown
Contributor Author

Thanks both points were valid. missing models is now rejected during construction and an invalid list alignment quarantines every routable endpoint instead of treating them as healthy. I added regression coverage for both cases.

@Alex-Wengg
Alex-Wengg requested a review from chrikrah September 13, 2026 13:33

@Shaoting-Feng Shaoting-Feng left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@Alex-Wengg

Copy link
Copy Markdown
Contributor Author

@Shaoting-Feng The k8s-discovery-e2e-test failure looks infra-flaky rather than related to this change — the router pod was Running 1/1 the whole time, but the two opt125m engine pods never passed readiness within the 20-min timeout. The same workflow passed on main two hours later (run 34759534802 vs the main run at 14:26 UTC).

I've updated the branch onto latest main. The workflows on the new head are queued pending approval, could you approve the runs when you get a chance? Thanks!

@Shaoting-Feng

Shaoting-Feng commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

@Alex-Wengg Yeah, it is a cold run issue causing the timeout.

@Shaoting-Feng
Shaoting-Feng enabled auto-merge (squash) September 15, 2026 05:50
@Alex-Wengg

Copy link
Copy Markdown
Contributor Author

Hi @Shaoting-Feng , the CI failure appears to be in the Kubernetes discovery setup. The vllm-opt125m-decode and vllm-opt125m-prefill pods stayed Running but never became Ready (0/1) until the 20-minute timeout, while the router pod was Ready. do we need to rerun this again or do a log check?

@chrikrah

Copy link
Copy Markdown
Contributor

The timeout is not the problem, so raising it would not help.

Measured across every attempt of router-e2e-test.yml, over the 91 runs created since 2026-08-20. That gives 48 records of k8s-discovery-e2e-test where Run all k8s discovery routing tests ran to a verdict:

records duration
passed 30 11.63 to 14.05 min, median 11.85
hit the cap 18 20.20 or 20.22 min

Nothing falls between 14.05 and 20.20. So no run would have passed at 25 minutes: readiness either arrives in about 12 minutes or it does not arrive.

Three of the 18 are on main, so this predates #1084. A rerun clears it about 62% of the time, which matches what you both saw.

Read through /runs/{id}/attempts/{n}/jobs, since /runs/{id}/jobs returns only the latest attempt. I did not run the suite and I have not diagnosed why readiness stalls.

@Alex-Wengg

Copy link
Copy Markdown
Contributor Author

Hi @Shaoting-Feng, just checking in since it's been about a week. I've updated the branch onto latest main. Has the k8s-discovery readiness issue been resolved on the runners? If not, would it be possible to merge as is? Happy to make any other changes if needed. Thanks!

@chrikrah chrikrah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

e70018e closes both of my earlier findings. I should have said so on 13 September when you asked. Sorry for leaving an open review request on a pull request that already had an approval.

Verified at a4c506d:

$ python -m pytest src/tests/test_static_service_discovery.py -q
13 passed      # main: 8 passed

Finding 1 was that models escaped validation. It now has its own check ahead of the loop. The is not None guard covers only the optional lists:

models=None        -> ValueError: models must be provided
length mismatch    -> ValueError: urls (2) and models (1) must have the same length
labels mismatch    -> ValueError: urls (1) and model_labels (2) must have the same length
all aligned        -> accepted

Finding 2 was the bare return []. The only caller reads it as all-healthy. Now get_unhealthy_endpoint_hashes returns a hash for every url and model pair when validation fails, so a bad config quarantines.

No objection from me. One limit: I did not run the wider suite, and I did not run anything that needs a cluster.

@Alex-Wengg

Copy link
Copy Markdown
Contributor Author

@ruizhang0101 @Shaoting-Feng thanks for updating the branch. The 5 CI workflows are waiting on "Approve and run" since this is a fork PR. Could one of you approve them so the checks can finish?

@Shaoting-Feng
Shaoting-Feng merged commit aa7f139 into vllm-project:main Oct 6, 2026
16 checks passed
@Alex-Wengg

Copy link
Copy Markdown
Contributor Author

@chrikrah let's gooo, it's been merged in.

@Shaoting-Feng thank you for helping us get this merged in

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

Labels

None yet

Projects

None yet

4 participants