Commit 105c1df
fix(uninstall): do not fail cleanup on another user's gateway process (#9005)
## Summary
`nemoclaw uninstall` exited 1 on a multi-user host whenever another
user's `openshell-gateway` process was running, because the host gateway
scan signalled every process that `pgrep` returned and counted the
resulting permission error as a cleanup failure. Uninstall now keeps a
gateway process that another non-root user owns running, names it, and
continues with the remaining cleanup. A `root`-owned process and the
gateway process that this installation recorded still block cleanup as
before.
## Related Issue
Fixes #8996
## Changes
- `src/lib/onboard/host-gateway-process.ts`: classify a swept process by
owner. A process that another non-root user owns, and that this
installation did not record in its PID file, is reported through a new
optional `foreignUserPids` result field and left running instead of
counting as a failure. Gateway-scoped stops and `root`-owned processes
are unchanged.
- `src/lib/onboard/host-gateway-process.test.ts`: cover foreign-user
preservation, current-user and root-owned handling, and the PID-file
exception that still stops a process recorded by this installation.
- `src/lib/actions/uninstall/run-plan-foreign-user-gateway.test.ts`:
cover the uninstall exit status for another user's process and for a
current-user process that cannot be stopped.
- `docs/manage-sandboxes/uninstall-nemoclaw.mdx`,
`docs/reference/commands.mdx`, `docs/reference/troubleshooting.mdx`:
explain which processes uninstall stops, when preservation can still
exit successfully, and why another user's process can keep a port in
use.
- `agents/hermes/Dockerfile`,
`agents/hermes/validate-env-secret-boundary.py`,
`test/hermes-env-secret-boundary-hardening.test.ts`: admit and validate
the provider-assigned Hermes API port required by the current
managed-image runtime.
`foreignUserPids` is optional because
`src/lib/actions/sandbox/destroy-gateway.ts`,
`src/lib/onboard/docker-driver-gateway-prelaunch.ts`, and
`src/lib/tunnel/gateway-port-release-test-helpers.ts` build this result
type directly, and a required field would change all three without a
behavior need.
`src/lib/actions/uninstall/run-plan-foreign-user-gateway.test.ts`
protects the uninstall exit-code contract that depends on it.
## Type of Change
- [ ] Code change (feature, bug fix, or refactor)
- [x] Code change with doc updates
- [ ] Doc only (prose changes, no code sample modifications)
- [ ] Doc only (includes code sample changes)
## Quality Gates
- [x] Tests added or updated for changed behavior
- [ ] Existing tests cover changed behavior — justification:
- [ ] Tests not applicable — justification:
- [x] Docs updated for user-facing behavior changes
- [ ] Docs not applicable — justification:
- [x] Sensitive paths changed (security, policy, credentials, preflight,
onboarding, inference, runner, sandbox, or messaging)
- [x] Sensitive-path review completed or maintainer-approved waiver
recorded — reviewer/approval link/justification: The current changes
preserve process-ownership boundaries and keep the Hermes runtime
environment allowlist constrained to the validated numeric API-port
field. Raw-secret rejection and supervisor-identity checks remain
covered.
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:
## Documentation Writer Review
- [x] Documentation writer subagent reviewed the completed changes
- Result: `docs-updated`
- Evidence: Updated `docs/manage-sandboxes/uninstall-nemoclaw.mdx`,
`docs/reference/commands.mdx`, and `docs/reference/troubleshooting.mdx`
to document foreign-user gateway preservation, exit-status behavior,
recorded and root-owned process handling, and port remediation. The
signed main merge preserved these #9005 changes, and the documentation
matches the related uninstall behavior tests and follows `WRITING.md`
and `docs/CONTRIBUTING.md`.
- Agent: Codex documentation writer
<!-- docs-review-head-sha: 1ac20a1 -->
<!-- docs-review-agents-blob-sha: e30afb2 -->
## Verification
- [x] PR description includes a `Signed-off-by:` line and every commit
appears as `Verified` in GitHub
- [x] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or
`npm run validate:pr` passed after refreshing `origin/main` when hooks
were skipped or unavailable
- [x] Targeted behavior tests pass for the current change set, or tests
are marked not applicable above — command/result or justification: `npx
vitest run --project cli src/lib/onboard/host-gateway-process.test.ts
src/lib/actions/uninstall/run-plan-foreign-user-gateway.test.ts` — 2
files, 21 tests passed; `npx vitest run
test/hermes-env-secret-boundary-hardening.test.ts
test/hermes-api-port-startup.test.ts
test/hermes-openshell-runtime-env-boundary.test.ts` — 3 files, 33 tests
passed, 1 platform-specific skip; the OpenShell 0.0.101
managed-bootstrap activation passed locally
- [ ] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — command/result:
- [x] Quality Gates section completed with required justifications or
waivers
- [x] No secrets, API keys, or credentials committed
- [ ] `npm run docs` builds without warnings (doc changes only)
- [x] Doc pages follow the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md)
(doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages only)
---
Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Uninstall now avoids stopping unrecorded gateway processes owned by
another non-root user.
* Uninstall reports the process owner and PID when a gateway remains
active.
* Stop failures provide `sudo kill -9` guidance.
* Scoped and all-port uninstall operations now return a failure status
when processes cannot be stopped, while full uninstall continues
cleanup.
* **Documentation**
* Added guidance for resolving gateway port conflicts caused by another
user's process.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Prekshi Vyas <34834085+prekshivyas@users.noreply.github.com>
Co-authored-by: Prekshi Vyas <prekshiv@nvidia.com>
Co-authored-by: Apurv Kumaria <akumaria@nvidia.com>
Co-authored-by: Rebecca Sliter <571084+rsliter@users.noreply.github.com>1 parent e25ae07 commit 105c1df
6 files changed
Lines changed: 248 additions & 1 deletion
File tree
- docs
- manage-sandboxes
- reference
- src/lib
- actions/uninstall
- onboard
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
118 | 125 | | |
119 | 126 | | |
120 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4153 | 4153 | | |
4154 | 4154 | | |
4155 | 4155 | | |
| 4156 | + | |
| 4157 | + | |
| 4158 | + | |
| 4159 | + | |
| 4160 | + | |
| 4161 | + | |
| 4162 | + | |
4156 | 4163 | | |
4157 | 4164 | | |
4158 | 4165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
435 | 438 | | |
436 | 439 | | |
437 | 440 | | |
| |||
Lines changed: 99 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
68 | 72 | | |
69 | 73 | | |
70 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
71 | 79 | | |
72 | 80 | | |
73 | 81 | | |
| |||
350 | 358 | | |
351 | 359 | | |
352 | 360 | | |
353 | | - | |
| 361 | + | |
354 | 362 | | |
355 | 363 | | |
356 | 364 | | |
| |||
377 | 385 | | |
378 | 386 | | |
379 | 387 | | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
380 | 475 | | |
381 | 476 | | |
382 | 477 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
204 | 205 | | |
205 | 206 | | |
206 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
207 | 233 | | |
208 | 234 | | |
209 | 235 | | |
| |||
417 | 443 | | |
418 | 444 | | |
419 | 445 | | |
| 446 | + | |
420 | 447 | | |
421 | 448 | | |
422 | 449 | | |
| |||
546 | 573 | | |
547 | 574 | | |
548 | 575 | | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
549 | 585 | | |
550 | 586 | | |
551 | 587 | | |
| |||
0 commit comments