Repository navigation
fix(onboard): use OpenShell gateway user service #4580
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 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
04b7523
fix(onboard): use OpenShell gateway user service
ericksoa 90a5959
refactor(onboard): keep gateway service start outside entrypoint
ericksoa 795b3c3
refactor(onboard): keep service lifecycle out of entrypoint
ericksoa 098007d
fix(installer): verify upstream OpenShell package installer
ericksoa c24aa4e
refactor(onboard): scope OpenShell gateway service handoff
ericksoa 3f68c53
test(e2e): fix OpenShell version pin checksum fixture
ericksoa ce9cb66
fix(onboard): trust package OpenShell gateway units
ericksoa 59b38da
docs(onboard): address OpenShell sandbox override wording
ericksoa 7523a1e
fix(onboard): tighten OpenShell service handoff
ericksoa 48b9a36
Merge remote-tracking branch 'origin/main' into fix/4423-openshell-se…
cv 19b6853
Merge branch 'main' into fix/4423-openshell-service-lifecycle-v60
cv 4189ac6
fix(onboard): satisfy docs and growth gates
cv eee1212
refactor(onboard): extract package gateway env handoff
cv 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
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,108 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { describe, expect, it, vi } from "vitest"; | ||
|
|
||
| import { | ||
| getOpenShellGatewayUserServicePaths, | ||
| hasOpenShellGatewayUserService, | ||
| startOpenShellGatewayUserService, | ||
| type SpawnSyncLikeResult, | ||
| } from "./docker-driver-gateway-service"; | ||
|
|
||
| function spawnResult(status = 0, stderr = ""): SpawnSyncLikeResult { | ||
| return { | ||
| error: undefined, | ||
| status, | ||
| stderr, | ||
| stdout: "", | ||
| }; | ||
| } | ||
|
|
||
| describe("docker-driver-gateway-service", () => { | ||
| it("detects the upstream OpenShell user service only on Linux", () => { | ||
| const existsSync = (candidate: string) => | ||
| candidate === "/usr/lib/systemd/user/openshell-gateway.service"; | ||
|
|
||
| expect(hasOpenShellGatewayUserService({ existsSync, platform: "linux" })).toBe(true); | ||
| expect(hasOpenShellGatewayUserService({ existsSync, platform: "darwin" })).toBe(false); | ||
| expect(getOpenShellGatewayUserServicePaths()).toEqual([ | ||
| "/usr/local/lib/systemd/user/openshell-gateway.service", | ||
| "/usr/lib/systemd/user/openshell-gateway.service", | ||
| "/lib/systemd/user/openshell-gateway.service", | ||
| ]); | ||
| }); | ||
|
|
||
| it("ignores stale per-user service units so standalone fallback remains available", () => { | ||
| const existsSync = vi.fn( | ||
| (candidate: string) => | ||
| candidate === "/home/nvidia/.config/systemd/user/openshell-gateway.service", | ||
| ); | ||
|
|
||
| expect(hasOpenShellGatewayUserService({ existsSync, platform: "linux" })).toBe(false); | ||
| expect(existsSync.mock.calls.flat()).not.toContain( | ||
| "/home/nvidia/.config/systemd/user/openshell-gateway.service", | ||
| ); | ||
| }); | ||
|
|
||
| it("restarts the upstream user service with systemctl --user", () => { | ||
| const spawnSyncImpl = vi.fn((_command: string, _args: string[]) => spawnResult()); | ||
|
|
||
| const result = startOpenShellGatewayUserService({ | ||
| commandExists: (command) => command === "systemctl", | ||
| env: {}, | ||
| existsSync: (candidate) => candidate === "/lib/systemd/user/openshell-gateway.service", | ||
| platform: "linux", | ||
| spawnSyncImpl, | ||
| }); | ||
|
|
||
| expect(result).toEqual({ attempted: true, fallbackAllowed: false, started: true }); | ||
| expect(spawnSyncImpl.mock.calls.map(([command, args]) => [command, args])).toEqual([ | ||
| ["systemctl", ["--user", "daemon-reload"]], | ||
| ["systemctl", ["--user", "enable", "openshell-gateway"]], | ||
| ["systemctl", ["--user", "restart", "openshell-gateway"]], | ||
| ]); | ||
| }); | ||
|
|
||
| it("allows standalone fallback when the user systemd manager is unavailable", () => { | ||
| const result = startOpenShellGatewayUserService({ | ||
| commandExists: () => true, | ||
| env: {}, | ||
| existsSync: () => true, | ||
| platform: "linux", | ||
| spawnSyncImpl: vi.fn((_command: string, args: string[]) => | ||
| Array.isArray(args) && args.includes("daemon-reload") | ||
| ? spawnResult(1, "Failed to connect to bus") | ||
| : spawnResult(), | ||
| ), | ||
| }); | ||
|
|
||
| expect(result).toMatchObject({ | ||
| attempted: true, | ||
| fallbackAllowed: true, | ||
| started: false, | ||
| }); | ||
| expect(result.reason).toContain("Failed to connect to bus"); | ||
| }); | ||
|
|
||
| it("does not silently fall back when the installed service fails to restart", () => { | ||
| const result = startOpenShellGatewayUserService({ | ||
| commandExists: () => true, | ||
| env: {}, | ||
| existsSync: () => true, | ||
| platform: "linux", | ||
| spawnSyncImpl: vi.fn((_command: string, args: string[]) => | ||
| Array.isArray(args) && args.includes("restart") | ||
| ? spawnResult(1, "Job failed") | ||
| : spawnResult(), | ||
| ), | ||
| }); | ||
|
|
||
| expect(result).toMatchObject({ | ||
| attempted: true, | ||
| fallbackAllowed: false, | ||
| started: false, | ||
| }); | ||
| expect(result.reason).toContain("Job failed"); | ||
| }); | ||
| }); |
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.