-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(onboard): keep the pre-rollback cause when a sandbox container cannot start #7998
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
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1355097
fix(onboard): keep the pre-rollback cause when a sandbox container ca…
yanyunl1991 9baefa6
merge(main): refresh #7998 against current main
cv 137c174
fix(onboard): harden pre-rollback diagnostics
cv 21f737c
merge: resolve conflicts with main
github-actions[bot] 67aec96
Merge branch 'main' into fix/onboard-prerollback-cause-7996
cv e1b69a9
Merge branch 'main' into fix/onboard-prerollback-cause-7996
cv d6fd82e
test(onboard): use keyed diagnostic fakes
cv 74a5ef5
fix(onboard): recognize BusyBox startup failure
cv c92ef0a
test(onboard): cover retained replacement retry
jyaunches 8f6de81
refactor(onboard): clarify cleanup disposition
jyaunches 0c82c79
fix(onboard): stabilize rollback diagnostics
jyaunches df64b8c
fix(onboard): make rollback cleanup target-safe
jyaunches c848b9d
test(onboard): cover rollback cleanup guards
jyaunches 1656cc3
docs(onboard): align rollback cleanup guidance
jyaunches 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,101 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import fs from "node:fs"; | ||
|
|
||
| import { describe, expect, it, vi } from "vitest"; | ||
|
|
||
| import { | ||
| buildDockerGpuMode, | ||
| type DockerGpuPatchFailureClassification, | ||
| printDockerGpuPatchFailureAndExit, | ||
| } from "./docker-gpu-patch"; | ||
|
|
||
| const PRE_ROLLBACK: DockerGpuPatchFailureClassification = { | ||
| kind: "patched_container_failed", | ||
| headline: "Patched GPU container exited with code 127 (--gpus all).", | ||
| summaryLines: ["patched_container_exit_code=127"], | ||
| hints: ["Exit code 127 means the sandbox image does not provide the managed startup command."], | ||
| }; | ||
|
|
||
| /** | ||
| * Drive the printer and return everything it wrote to stderr. Diagnostics | ||
| * persistence is disabled so the assertions only observe console output. | ||
| */ | ||
| function printAndCapture(deps: Parameters<typeof printDockerGpuPatchFailureAndExit>[2]): string { | ||
| const output: string[] = []; | ||
| const errorSpy = vi.spyOn(console, "error").mockImplementation((...args: unknown[]) => { | ||
| output.push(args.map(String).join(" ")); | ||
| }); | ||
| const mkdirSpy = vi.spyOn(fs, "mkdirSync").mockImplementation(() => { | ||
| throw new Error("diagnostics disabled for test"); | ||
| }); | ||
| const exitSpy = vi.spyOn(process, "exit").mockImplementation(((_code?: number) => { | ||
| throw new Error("__test_exit__"); | ||
| }) as never); | ||
| try { | ||
| expect(() => | ||
| printDockerGpuPatchFailureAndExit("alpha", new Error("supervisor did not reconnect"), deps), | ||
| ).toThrow(/__test_exit__/); | ||
| return output.join("\n"); | ||
| } finally { | ||
| exitSpy.mockRestore(); | ||
| mkdirSpy.mockRestore(); | ||
| errorSpy.mockRestore(); | ||
| } | ||
| } | ||
|
|
||
| describe("Docker GPU patch failure reporting (#7996)", () => { | ||
| it("prefers the pre-rollback verdict once rollback has erased the container", () => { | ||
| // Rollback already removed the replacement container, so a fresh inspect | ||
| // returns nothing and the sandbox only shows a generic Error phase. | ||
| const stderr = printAndCapture({ | ||
| runCaptureOpenshell: vi.fn(() => "alpha Error 1m ago\n"), | ||
| dockerCapture: vi.fn(() => ""), | ||
| context: { | ||
| sandboxName: "alpha", | ||
| newContainerId: "new-container-id", | ||
| selectedMode: buildDockerGpuMode("gpus"), | ||
| }, | ||
| preRollbackClassification: PRE_ROLLBACK, | ||
| }); | ||
|
|
||
| expect(stderr).toContain("Patched GPU container exited with code 127"); | ||
| expect(stderr).toContain("patched_container_exit_code=127"); | ||
| expect(stderr).toContain("does not provide the managed startup command"); | ||
| expect(stderr).not.toContain("entered Error phase"); | ||
| }); | ||
|
|
||
| it("keeps the freshly observed verdict when the container is still inspectable", () => { | ||
| // The live snapshot has first-hand evidence, so a stale pre-rollback | ||
| // verdict must not overwrite it. | ||
| const stderr = printAndCapture({ | ||
| runCaptureOpenshell: vi.fn(() => "alpha Error 1m ago\n"), | ||
| dockerCapture: vi.fn(() => JSON.stringify({ Status: "exited", ExitCode: 125 })), | ||
| context: { | ||
| sandboxName: "alpha", | ||
| newContainerId: "new-container-id", | ||
| selectedMode: buildDockerGpuMode("gpus"), | ||
| }, | ||
| preRollbackClassification: PRE_ROLLBACK, | ||
| }); | ||
|
|
||
| expect(stderr).toContain("Patched GPU container exited with code 125"); | ||
| expect(stderr).not.toContain("code 127"); | ||
| }); | ||
|
|
||
| it("falls back to the observed verdict when no pre-rollback verdict was captured", () => { | ||
| const stderr = printAndCapture({ | ||
| runCaptureOpenshell: vi.fn(() => "alpha Error 1m ago\n"), | ||
| dockerCapture: vi.fn(() => ""), | ||
| context: { | ||
| sandboxName: "alpha", | ||
| newContainerId: "new-container-id", | ||
| selectedMode: buildDockerGpuMode("gpus"), | ||
| }, | ||
| preRollbackClassification: null, | ||
| }); | ||
|
|
||
| expect(stderr).toContain("entered Error phase"); | ||
| }); | ||
| }); |
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
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
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.