-
Notifications
You must be signed in to change notification settings - Fork 3.1k
fix(onboard,uninstall): clearer diagnostics when no sandbox is registered #3464
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d6b011d
fix(onboard): clearer diagnostics when reusable gateway lacks GPU
laitingsheng 6cc0b14
fix(onboard): drop <name> from no-sandbox guidance and keep onboard.t…
laitingsheng 3e48de4
fix(onboard): point GPU-passthrough recovery at the actual loop fix
laitingsheng d67ba17
Merge branch 'main' into fix/3456-onboard-uninstall-clearer-diagnostics
laitingsheng 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
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,79 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { gpuPassthroughRecoveryLines, reportGpuPassthroughRecovery } from "./onboard/gpu-recovery"; | ||
|
|
||
| describe("gpuPassthroughRecoveryLines", () => { | ||
| it("clears the gateway directly when no sandboxes are registered (no NemoClaw uninstall, so the CLI survives)", () => { | ||
| const lines = gpuPassthroughRecoveryLines([]); | ||
| expect(lines).toEqual([ | ||
| " Existing gateway was started without GPU passthrough.", | ||
| " No sandboxes are registered, so there is nothing to destroy.", | ||
| " To enable GPU, clear the stale gateway and re-onboard:", | ||
| " openshell gateway destroy -g nemoclaw", | ||
| " nemoclaw onboard --gpu", | ||
| ]); | ||
| }); | ||
|
|
||
| it("falls back to a direct gateway-removal hint when the registry cannot be read", () => { | ||
| const lines = gpuPassthroughRecoveryLines(null); | ||
| expect(lines).toEqual([ | ||
| " Existing gateway was started without GPU passthrough.", | ||
| " Could not read the NemoClaw sandbox registry; cannot enumerate sandboxes.", | ||
| " To enable GPU, clear the stale gateway directly and re-onboard:", | ||
| " openshell gateway destroy -g nemoclaw", | ||
| " nemoclaw onboard --gpu", | ||
| ]); | ||
| }); | ||
|
|
||
| it("appends --cleanup-gateway to the single destroy command so the stale gateway is actually removed", () => { | ||
| const lines = gpuPassthroughRecoveryLines(["my-assistant"]); | ||
| expect(lines).toEqual([ | ||
| " Existing gateway was started without GPU passthrough.", | ||
| " To enable GPU, destroy the registered sandbox (`my-assistant`) and re-onboard:", | ||
| " nemoclaw my-assistant destroy --yes --cleanup-gateway", | ||
| " nemoclaw onboard --gpu", | ||
| ]); | ||
| }); | ||
|
|
||
| it("only puts --cleanup-gateway on the last destroy command when more than one sandbox is registered", () => { | ||
| const lines = gpuPassthroughRecoveryLines(["alpha", "beta"]); | ||
| expect(lines).toEqual([ | ||
| " Existing gateway was started without GPU passthrough.", | ||
| " To enable GPU, destroy the registered sandboxes (`alpha`, `beta`) and re-onboard:", | ||
| " nemoclaw alpha destroy --yes", | ||
| " nemoclaw beta destroy --yes --cleanup-gateway", | ||
| " nemoclaw onboard --gpu", | ||
| ]); | ||
| }); | ||
|
|
||
| it("never emits the literal `<name>` placeholder or a `nemoclaw uninstall && nemoclaw onboard` chain in any branch", () => { | ||
| for (const names of [null, [], ["x"], ["alpha", "beta"]] as const) { | ||
| const joined = gpuPassthroughRecoveryLines(names).join("\n"); | ||
| expect(joined).not.toContain("<name>"); | ||
| expect(joined).not.toContain("nemoclaw uninstall && nemoclaw onboard"); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe("reportGpuPassthroughRecovery", () => { | ||
| it("routes the registered sandbox names through the printer", () => { | ||
| const printed: string[] = []; | ||
| reportGpuPassthroughRecovery((line) => printed.push(line), () => ["alpha"]); | ||
| expect(printed).toEqual(gpuPassthroughRecoveryLines(["alpha"])); | ||
| }); | ||
|
|
||
| it("falls back to the registry-unreadable guidance when the lookup throws (does not collapse to 'no sandboxes')", () => { | ||
| const printed: string[] = []; | ||
| reportGpuPassthroughRecovery( | ||
| (line) => printed.push(line), | ||
| () => { | ||
| throw new Error("registry unreachable"); | ||
| }, | ||
| ); | ||
| expect(printed).toEqual(gpuPassthroughRecoveryLines(null)); | ||
| expect(printed.join("\n")).toContain("Could not read the NemoClaw sandbox registry"); | ||
| }); | ||
| }); | ||
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,55 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| const GATEWAY_REMOVAL_COMMAND = "openshell gateway destroy -g nemoclaw"; | ||
| const ONBOARD_GPU_COMMAND = "nemoclaw onboard --gpu"; | ||
|
|
||
| export function gpuPassthroughRecoveryLines(registeredNames: readonly string[] | null): string[] { | ||
| const lines: string[] = [" Existing gateway was started without GPU passthrough."]; | ||
| if (registeredNames === null) { | ||
| lines.push(" Could not read the NemoClaw sandbox registry; cannot enumerate sandboxes."); | ||
| lines.push(" To enable GPU, clear the stale gateway directly and re-onboard:"); | ||
| lines.push(` ${GATEWAY_REMOVAL_COMMAND}`); | ||
| lines.push(` ${ONBOARD_GPU_COMMAND}`); | ||
| return lines; | ||
| } | ||
| if (registeredNames.length === 0) { | ||
| lines.push(" No sandboxes are registered, so there is nothing to destroy."); | ||
| lines.push(" To enable GPU, clear the stale gateway and re-onboard:"); | ||
| lines.push(` ${GATEWAY_REMOVAL_COMMAND}`); | ||
| lines.push(` ${ONBOARD_GPU_COMMAND}`); | ||
| return lines; | ||
| } | ||
| const plural = registeredNames.length === 1 ? "" : "es"; | ||
| const list = registeredNames.map((n) => `\`${n}\``).join(", "); | ||
| lines.push(` To enable GPU, destroy the registered sandbox${plural} (${list}) and re-onboard:`); | ||
| registeredNames.forEach((name, index) => { | ||
| const isLast = index === registeredNames.length - 1; | ||
| const flags = isLast ? " --yes --cleanup-gateway" : " --yes"; | ||
| lines.push(` nemoclaw ${name} destroy${flags}`); | ||
| }); | ||
| lines.push(` ${ONBOARD_GPU_COMMAND}`); | ||
| return lines; | ||
| } | ||
|
|
||
| function defaultRegisteredSandboxNames(): readonly string[] | null { | ||
| try { | ||
| const registry = require("../state/registry") as typeof import("../state/registry"); | ||
| return registry.listSandboxes().sandboxes.map((s) => s.name).filter(Boolean); | ||
| } catch { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| export function reportGpuPassthroughRecovery( | ||
| emit: (line: string) => void = console.error, | ||
| listRegisteredSandboxes: () => readonly string[] | null = defaultRegisteredSandboxNames, | ||
| ): void { | ||
| let names: readonly string[] | null; | ||
| try { | ||
| names = listRegisteredSandboxes(); | ||
| } catch { | ||
| names = null; | ||
| } | ||
| for (const line of gpuPassthroughRecoveryLines(names)) emit(line); | ||
| } |
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.