-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(onboard): require a healthy endpoint before accepting the model router #9495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
apurvvkumaria
merged 13 commits into
NVIDIA:main
from
udsy19:fix/router-health-zero-endpoints
Aug 20, 2026
+158
−65
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e64af5a
fix(onboard): require a healthy endpoint before the router startup po…
udsy19 aa5e59d
refactor(onboard): one router readiness predicate for both acceptance…
udsy19 8677b80
fix(onboard): reuse an existing router only when it names a healthy e…
udsy19 d9444d0
merge: refresh PR #9495 with latest main
jyaunches 9b9a2d8
merge: refresh PR #9495 with latest main
jyaunches cafdf6d
merge: refresh PR #9495 with latest main
jyaunches 7820449
merge: refresh PR #9495 with latest main
jyaunches 4cb817b
merge: refresh PR #9495 with latest main
jyaunches f55e114
merge: refresh PR #9495 with latest main
jyaunches 8f09a7f
Merge branch 'main' into fix/router-health-zero-endpoints
prekshivyas d3b4674
Merge branch 'main' into fix/router-health-zero-endpoints
prekshivyas 1b335c9
Merge branch 'main' into fix/router-health-zero-endpoints
apurvvkumaria 2eb93a5
merge: refresh PR #9495 with current main
apurvvkumaria File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { beforeEach, describe, expect, it, vi } from "vitest"; | ||
|
|
||
| import { reconcileModelRouter } from "./model-router"; | ||
|
|
||
| const RECORDED_ROUTER_PID = 4321; | ||
|
|
||
| const holder = vi.hoisted(() => ({ | ||
| snapshotBody: null as string | null, | ||
| stopped: [] as Array<[number, number]>, | ||
| reachabilityProbes: 0, | ||
| })); | ||
|
|
||
| // `stopModelRouterProcess` throws a sentinel so each case ends at the | ||
| // reuse decision. Restarting the router is `startModelRouter`'s contract and | ||
| // is covered by `test/onboard-model-router.test.ts`. | ||
| vi.mock("./model-router-process", () => ({ | ||
| ROUTER_HEALTH_TIMEOUT_MS: 3_000, | ||
| getRouterHealthSnapshot: vi.fn(async () => ({ healthy: true, body: holder.snapshotBody })), | ||
| isRouterHealthy: vi.fn(async () => true), | ||
| doesModelRouterProcessOwnPort: vi.fn(() => true), | ||
| inspectModelRouterProcessForPort: vi.fn(() => ({ status: "missing" as const })), | ||
| stopModelRouterProcess: vi.fn(async (pid: number, port: number) => { | ||
| holder.stopped.push([pid, port]); | ||
| throw new Error("router restart reached"); | ||
| }), | ||
| })); | ||
|
|
||
| vi.mock("../credentials/store", () => ({ | ||
| normalizeCredentialValue: (value: string) => value, | ||
| resolveProviderCredential: () => "", | ||
| saveCredential: vi.fn(), | ||
| })); | ||
|
|
||
| vi.mock("./credential-env", () => ({ | ||
| hydrateCredentialEnv: () => "nvapi-TEST-NOT-A-REAL-ROUTER-KEY", | ||
| })); | ||
|
|
||
| vi.mock("../state/onboard-session", () => ({ | ||
| loadSession: () => ({ | ||
| routerPid: RECORDED_ROUTER_PID, | ||
| routerCredentialHash: "MATCHING-HASH", | ||
| }), | ||
| updateSession: vi.fn(), | ||
| })); | ||
|
|
||
| vi.mock("../security/credential-hash", () => ({ hashCredential: () => "MATCHING-HASH" })); | ||
|
|
||
| vi.mock("./host-service-reachability", () => ({ | ||
| probeHostServiceSandboxReachability: vi.fn(async () => { | ||
| holder.reachabilityProbes += 1; | ||
| return { ok: true }; | ||
| }), | ||
| formatHostServiceUnreachableMessage: () => "", | ||
| })); | ||
|
|
||
| describe("model router reconciliation", () => { | ||
| beforeEach(() => { | ||
| holder.snapshotBody = null; | ||
| holder.stopped = []; | ||
| holder.reachabilityProbes = 0; | ||
| }); | ||
|
|
||
| it("reuses a recorded router whose health snapshot names a healthy endpoint", async () => { | ||
| holder.snapshotBody = JSON.stringify({ | ||
| healthy_endpoints: [{ api_base: "https://integrate.api.nvidia.com/v1" }], | ||
| unhealthy_endpoints: [], | ||
| }); | ||
|
|
||
| await reconcileModelRouter(); | ||
|
|
||
| expect(holder.stopped).toEqual([]); | ||
| expect(holder.reachabilityProbes).toBe(1); | ||
| }); | ||
|
|
||
| it("restarts a recorded router that answers 2xx with no healthy endpoint (#9437)", async () => { | ||
| holder.snapshotBody = JSON.stringify({ | ||
| healthy_endpoints: [], | ||
| unhealthy_endpoints: [{ api_base: "https://integrate.api.nvidia.com/v1" }], | ||
| }); | ||
|
|
||
| await expect(reconcileModelRouter()).rejects.toThrow("router restart reached"); | ||
|
|
||
| expect(holder.stopped).toEqual([[RECORDED_ROUTER_PID, expect.any(Number)]]); | ||
| expect(holder.reachabilityProbes).toBe(0); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.