Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
208e753
fix(uninstall): delete the scoped sandbox before removing its unit (#…
harjothkhara Aug 4, 2026
2356fa3
test(uninstall): cover the scoped sandbox-delete failure path (#8220)
harjothkhara Aug 4, 2026
5e4c85b
docs(uninstall): note partial completion before a scoped cleanup fail…
harjothkhara Aug 4, 2026
29bc287
Merge branch 'main' into oss-find/nemoclaw-2026-08-04
cv Aug 5, 2026
814d3d4
Merge branch 'main' into oss-find/nemoclaw-2026-08-04
cv Aug 5, 2026
0fb0f7e
Merge branch 'main' into oss-find/nemoclaw-2026-08-04
senthilr-nv Aug 5, 2026
d3fe2d5
merge(main): refresh PR #8259 after scoped cleanup hardening
cv Aug 5, 2026
29c0bbc
merge(main): refresh PR 8259
cv Aug 5, 2026
bffbc08
test(uninstall): clarify scoped cleanup failure
cv Aug 5, 2026
1a9ed25
merge(main): refresh PR 8259
cv Aug 5, 2026
282e41b
merge(main): refresh PR 8259
cv Aug 5, 2026
05294e7
merge(main): refresh PR 8259
cv Aug 5, 2026
f5f3a33
Merge branch 'main' into oss-find/nemoclaw-2026-08-04
senthilr-nv Aug 5, 2026
4c44520
test(uninstall): cover the scoped gateway-removal failure path (#8220)
harjothkhara Aug 5, 2026
fa8c048
Merge branch 'main' into oss-find/nemoclaw-2026-08-04
senthilr-nv Aug 5, 2026
829a112
merge(main): refresh PR #8259
cjagwani Aug 5, 2026
c96b57d
merge(main): refresh PR #8259
cjagwani Aug 5, 2026
cfc6ce2
chore: resynchronize PR #8259 head
cjagwani Aug 5, 2026
4388675
docs(uninstall): preserve gateway port on retry
cv Aug 5, 2026
b4a82ff
merge(main): refresh PR #8259
cjagwani Aug 5, 2026
6697d74
merge(pr): preserve concurrent #8259 documentation
cjagwani Aug 5, 2026
9830a2b
merge(main): refresh PR #8259
cv Aug 5, 2026
ed54e22
merge(main): refresh PR #8259
cjagwani Aug 5, 2026
3431a02
merge(main): refresh PR #8259
cjagwani Aug 5, 2026
c854415
merge(main): refresh PR #8259
cv Aug 5, 2026
033cedd
Merge branch 'main' into oss-find/nemoclaw-2026-08-04
apurvvkumaria Aug 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/manage-sandboxes/uninstall-nemoclaw.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ Resolve the reported error, inspect the remaining gateways with `openshell gatew
Default-port uninstall removes NemoClaw-managed entries in `openshell/gateway.env`.
For a NemoClaw-managed authority, it also removes only NemoClaw's marked Linux gateway unit.
It preserves upstream Linux package units, the macOS Homebrew service, and unrelated environment entries.
Gateway-scoped cleanup removes that gateway's OpenShell resources first, then the marked Linux unit.
The OpenShell gateway service therefore keeps running while uninstall deletes the selected gateway's sandboxes.
If that OpenShell cleanup fails, uninstall exits nonzero and preserves the marked Linux unit and the gateway process.
That cleanup can partially complete before the failure.
Resolve the reported error.
Inspect the remaining gateways with `openshell gateway list`.
Rerun `NEMOCLAW_GATEWAY_PORT=<port> $$nemoclaw uninstall` with the gateway port from the failed uninstall.
For an externally supervised authority, uninstall preserves the local gateway state used by the running process in both full and gateway-scoped cleanup.
It also preserves the gateway process, supervisor resources, marked Linux unit, Docker resources, OpenShell binaries, and the declared external state directory.
A custom-port uninstall does not stop or remove the default gateway service or its environment file.
Expand Down
7 changes: 7 additions & 0 deletions docs/reference/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3654,6 +3654,13 @@ The compatibility `--gateway` flag cannot select another instance: when present,
Default-port uninstall removes NemoClaw-managed entries in `openshell/gateway.env`.
For a NemoClaw-managed authority, it also removes only NemoClaw's marked Linux gateway unit.
It preserves upstream Linux package units, the macOS Homebrew service, and unrelated environment entries.
Gateway-scoped cleanup removes that gateway's OpenShell resources first, then the marked Linux unit.
The OpenShell gateway service therefore keeps running while uninstall deletes the selected gateway's sandboxes.
If that OpenShell cleanup fails, uninstall exits nonzero and preserves the marked Linux unit and the gateway process.
That cleanup can partially complete before the failure.
Resolve the reported error.
Inspect the remaining gateways with `openshell gateway list`.
Rerun `NEMOCLAW_GATEWAY_PORT=<port> $$nemoclaw uninstall` with the gateway port from the failed uninstall.
For an externally supervised authority, uninstall preserves the selected local gateway state in both full and gateway-scoped cleanup.
It also preserves the gateway process, supervisor resources, marked Linux unit, Docker resources, OpenShell binaries, and the declared external state directory.
A custom-port uninstall does not stop or remove the default gateway service or its environment file.
Expand Down
117 changes: 117 additions & 0 deletions src/lib/actions/uninstall/run-plan-gateway-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ function writeGatewayEnv(test: Fixture, contents = "OPENSHELL_SERVER_PORT=8080\n
return envPath;
}

function writeSelectedSandboxRegistry(test: Fixture, sandboxName: string): void {
const registryPath = path.join(test.home, ".nemoclaw", "sandboxes.json");
fs.mkdirSync(path.dirname(registryPath), { recursive: true });
fs.writeFileSync(
registryPath,
`${JSON.stringify({
defaultSandbox: sandboxName,
sandboxes: {
[sandboxName]: { name: sandboxName, gatewayName: "nemoclaw", gatewayPort: 8080 },
},
})}\n`,
);
}

function writeGatewayState(test: Fixture): string {
const configPath = path.join(
test.home,
Expand Down Expand Up @@ -184,6 +198,109 @@ describe("uninstall OpenShell gateway user service", () => {
expect(fs.existsSync(gatewayStatePath)).toBe(true);
});

it("deletes the selected sandbox before it disables the marked Linux unit on scoped uninstall (#8220)", () => {
const test = fixture(true);
const servicePath = writeManagedService(test);
writeSelectedSandboxRegistry(test, "my-assistant");
const calls: string[][] = [];
const dockerCalls: string[][] = [];
let gatewayStopped = false;

const result = uninstall(
test,
false,
{
commandExists: (command) => command === "systemctl" || command === "docker",
run: (command, args) => {
calls.push([command, ...args]);
gatewayStopped ||= command === "systemctl" && args.includes("disable");
// `systemctl disable --now` also stops the OpenShell gateway service,
// so every scoped `openshell` call fails once the unit is disabled.
return command === "openshell" && gatewayStopped
? { status: 1, stdout: "", stderr: "gateway unreachable" }
: ok();
},
runDocker: (args) => {
dockerCalls.push(args);
return args[0] === "ps"
? ok("sandbox-id openshell/sandbox openshell-cluster-nemoclaw\n")
: ok();
},
},
[{ name: "nemoclaw" }, { name: "nemoclaw-8081" }],
);

const deletedAt = calls.findIndex(
(call) => call[0] === "openshell" && call[1] === "sandbox" && call[2] === "delete",
);
const disabledAt = calls.findIndex(
(call) => call[0] === "systemctl" && call.includes("disable"),
);

expect(result.exitCode).toBe(0);
expect(deletedAt).toBeGreaterThanOrEqual(0);
expect(disabledAt).toBeGreaterThan(deletedAt);
expect(dockerCalls).toContainEqual(["rm", "-f", "sandbox-id"]);
expect(fs.existsSync(servicePath)).toBe(false);
});

it("preserves the marked Linux unit when scoped sandbox deletion fails (#8220)", () => {
const test = fixture(true);
const servicePath = writeManagedService(test);
writeSelectedSandboxRegistry(test, "my-assistant");
const calls: string[][] = [];

const result = uninstall(
test,
false,
{
commandExists: (command) => command === "systemctl",
run: (command, args) => {
calls.push([command, ...args]);
return command === "openshell" && args[0] === "sandbox"
? { status: 1, stdout: "", stderr: "sandbox unreachable" }
: ok();
},
},
[{ name: "nemoclaw" }, { name: "nemoclaw-8081" }],
);

// Sandbox deletion failed, so uninstall returns before it removes the gateway registration.
// It preserves the marked Linux unit and the running OpenShell gateway service for a retry.
expect(result.exitCode).toBe(1);
expect(fs.existsSync(servicePath)).toBe(true);
expect(calls.some((call) => call[0] === "systemctl" && call.includes("disable"))).toBe(false);
});

it("preserves the marked Linux unit when scoped gateway registration removal fails (#8220)", () => {
const test = fixture(true);
const servicePath = writeManagedService(test);
writeSelectedSandboxRegistry(test, "my-assistant");
const calls: string[][] = [];

const result = uninstall(
test,
false,
{
commandExists: (command) => command === "systemctl",
run: (command, args) => {
calls.push([command, ...args]);
return command === "openshell" && args[0] === "gateway" && args[1] === "remove"
? { status: 1, stdout: "", stderr: "gateway registration is busy" }
: ok();
},
},
[{ name: "nemoclaw" }, { name: "nemoclaw-8081" }],
);

// Sandbox deletion succeeded, so this pins the second cleanup boundary: registration
// removal failed, and uninstall still returns before it removes the gateway service.
expect(calls).toContainEqual(["openshell", "sandbox", "delete", "my-assistant"]);
expect(result.exitCode).toBe(1);
expect(fs.existsSync(servicePath)).toBe(true);
expect(calls.some((call) => call[0] === "systemctl" && call.includes("disable"))).toBe(false);
});

it("removes only the marked Linux unit and managed env on full uninstall (#6903)", () => {
const test = fixture(true);
const servicePath = writeManagedService(test);
Expand Down
27 changes: 23 additions & 4 deletions src/lib/actions/uninstall/run-plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,20 @@ function removeNemoclawOpenShellGatewayUserService(runtime: UninstallRuntime): b
return true;
}

// scripts/install.sh stages the NemoClaw-managed gateway user service only for
// the default gateway port, so an uninstall run for any other port leaves it in
// place. `--keep-openshell` and an externally supervised authority leave it in
// place too.
function removeManagedDefaultGatewayUserService(
runtime: UninstallRuntime,
options: UninstallRunOptions,
externallySupervised: boolean,
): boolean {
return options.keepOpenShell || externallySupervised || GATEWAY_PORT !== DEFAULT_GATEWAY_PORT
? true
: removeNemoclawOpenShellGatewayUserService(runtime);
}

function removeNemoclawOpenShellGatewayEnv(
paths: UninstallPaths,
runtime: UninstallRuntime,
Expand Down Expand Up @@ -1799,12 +1813,14 @@ function executePlan(
if (!scopedToSelectedGateway && !removeManagedDistributedVllmRuntime(paths, runtime)) {
return { ok: false };
}
// #8220: a gateway-scoped uninstall still needs the selected OpenShell
// gateway service running to delete its sandbox, so "OpenShell resources"
// removes that unit after the sandbox delete succeeds.
if (
!options.keepOpenShell &&
!externallySupervised &&
GATEWAY_PORT === DEFAULT_GATEWAY_PORT
!scopedToSelectedGateway &&
!removeManagedDefaultGatewayUserService(runtime, options, externallySupervised)
) {
if (!removeNemoclawOpenShellGatewayUserService(runtime)) ok = false;
ok = false;
}
if (!scopedToSelectedGateway) {
stopHelperServices(paths, runtime);
Expand Down Expand Up @@ -1874,6 +1890,9 @@ function executePlan(
return { ok: false };
}
if (scopedToSelectedGateway && !options.keepOpenShell && !externallySupervised) {
if (!removeManagedDefaultGatewayUserService(runtime, options, externallySupervised)) {
ok = false;
}
stopHostGatewayProcessesForUninstall(runtime, {
gatewayBin: runtime.env.NEMOCLAW_OPENSHELL_GATEWAY_BIN,
logNoProcesses: true,
Expand Down
Loading