Repository navigation
fix(gateway): install/manage OpenShell gateway service for reboot persistence - #6907
jibin7jose wants to merge 1 commit into
Conversation
…sistence (#6903)\n\nSigned-off-by: Jibin7Jose <[email protected]>
📝 WalkthroughWalkthroughAdds Linux systemd user-service staging for the NemoClaw-managed OpenShell gateway, selects and starts the available gateway service during onboarding, writes its environment file, and integrates service preservation or removal into uninstall behavior. ChangesNemoClaw gateway service lifecycle
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/lib/actions/uninstall/run-plan.ts (1)
943-955: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winKeep mode still removes the gateway state dir
removePath(paths.gatewayLocalStateDir, runtime)deletes~/.local/state/nemoclaw/openshell-docker-gateway/gateway.enveven whenkeepOpenShellis set. Skip that cleanup in keep mode, or the retained service will fail on its next start.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/actions/uninstall/run-plan.ts` around lines 943 - 955, Update the cleanup flow around removePath(paths.gatewayLocalStateDir, runtime) so gatewayLocalStateDir is preserved when options.keepOpenShell is true. Continue removing it in the non-keep path, while leaving the other state and configuration cleanup behavior unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/nemoclaw-openshell-gateway.service`:
- Line 6: Update the service template’s EnvironmentFile to use a substitution
for the gateway environment path instead of hard-coding $HOME/.local/state, and
ensure staging replaces that placeholder with the same env_dir/gateway.env
location used when writing the gateway environment, including XDG_STATE_HOME
overrides.
- Around line 1-2: Add the project-required SPDX license header at the beginning
of the openshell gateway service unit, before the [Unit] section, while
preserving the existing Description and service configuration.
- Around line 11-12: Update the service installation/setup flow associated with
WantedBy=default.target to manage and validate user lingering, ensuring the user
manager starts after a headless reboot and the gateway remains available without
login. Use loginctl to verify the target user’s Linger state and enable
lingering when needed, or explicitly narrow the documented lifecycle if
lingering is not supported.
In `@src/lib/onboard/docker-driver-gateway-service.ts`:
- Around line 122-129: Update the cleanup sequence around runSystemctlUser and
the fs.rmSync calls: disable and stop the service first, remove the unit and
environment files via getNemoclawGatewayUserServicePath and
getNemoclawGatewayEnvFilePath, then invoke runSystemctlUser(["daemon-reload"], {
env, spawnSyncImpl }) after both deletions.
- Around line 125-130: Update the test setup around the cleanup calls in the
relevant onboarding test to inject an rmSync mock alongside spawnSyncImpl, and
replace direct fs.rmSync usage with that injected dependency. Assert that rmSync
receives the gateway service and environment-file paths with force enabled,
ensuring no real user-service files are deleted.
---
Outside diff comments:
In `@src/lib/actions/uninstall/run-plan.ts`:
- Around line 943-955: Update the cleanup flow around
removePath(paths.gatewayLocalStateDir, runtime) so gatewayLocalStateDir is
preserved when options.keepOpenShell is true. Continue removing it in the
non-keep path, while leaving the other state and configuration cleanup behavior
unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: f990c4d2-7aa2-48ee-8deb-0dbfccc4a1ee
📒 Files selected for processing (7)
scripts/install-openshell.shscripts/nemoclaw-openshell-gateway.servicesrc/lib/actions/uninstall/run-plan.tssrc/lib/domain/uninstall/plan.tssrc/lib/onboard/docker-driver-gateway-env.tssrc/lib/onboard/docker-driver-gateway-service.test.tssrc/lib/onboard/docker-driver-gateway-service.ts
| [Unit] | ||
| Description=OpenShell Docker-driver gateway (NemoClaw-managed) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add the required SPDX header.
Proposed fix
+# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+
[Unit]📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| [Unit] | |
| Description=OpenShell Docker-driver gateway (NemoClaw-managed) | |
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | |
| # SPDX-License-Identifier: Apache-2.0 | |
| [Unit] | |
| Description=OpenShell Docker-driver gateway (NemoClaw-managed) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/nemoclaw-openshell-gateway.service` around lines 1 - 2, Add the
project-required SPDX license header at the beginning of the openshell gateway
service unit, before the [Unit] section, while preserving the existing
Description and service configuration.
Source: Coding guidelines
| After=network.target | ||
|
|
||
| [Service] | ||
| EnvironmentFile=%h/.local/state/nemoclaw/openshell-docker-gateway/gateway.env |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Keep the unit’s environment-file path aligned with XDG state.
This hard-codes $HOME/.local/state, but staging and onboarding write under $XDG_STATE_HOME when set. In that configuration, systemd reads a missing or stale file instead of the newly written gateway environment. Parameterize EnvironmentFile in the template and substitute the same env_dir/gateway.env path during staging.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/nemoclaw-openshell-gateway.service` at line 6, Update the service
template’s EnvironmentFile to use a substitution for the gateway environment
path instead of hard-coding $HOME/.local/state, and ensure staging replaces that
placeholder with the same env_dir/gateway.env location used when writing the
gateway environment, including XDG_STATE_HOME overrides.
| [Install] | ||
| WantedBy=default.target |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Enable lingering or this does not provide reboot persistence.
systemctl --user enable only starts this unit when the user manager runs; after reboot, that normally requires login unless lingering is enabled. A headless reboot therefore leaves the gateway down, contrary to the stated objective. Manage and validate user lingering, or explicitly narrow the supported lifecycle.
#!/bin/sh
loginctl show-user "$USER" -p Linger🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/nemoclaw-openshell-gateway.service` around lines 11 - 12, Update the
service installation/setup flow associated with WantedBy=default.target to
manage and validate user lingering, ensuring the user manager starts after a
headless reboot and the gateway remains available without login. Use loginctl to
verify the target user’s Linger state and enable lingering when needed, or
explicitly narrow the documented lifecycle if lingering is not supported.
| runSystemctlUser(["disable", "--now", NEMOCLAW_GATEWAY_USER_SERVICE], { env, spawnSyncImpl }); | ||
| runSystemctlUser(["daemon-reload"], { env, spawnSyncImpl }); | ||
|
|
||
| try { | ||
| fs.rmSync(getNemoclawGatewayUserServicePath(opts), { force: true }); | ||
| } catch {} | ||
| try { | ||
| fs.rmSync(getNemoclawGatewayEnvFilePath(opts), { force: true }); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Reload systemd after deleting the unit.
daemon-reload runs before the unit file is removed, leaving the current user manager with the deleted definition loaded. Disable/stop, remove the unit and env file, then reload.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/lib/onboard/docker-driver-gateway-service.ts` around lines 122 - 129,
Update the cleanup sequence around runSystemctlUser and the fs.rmSync calls:
disable and stop the service first, remove the unit and environment files via
getNemoclawGatewayUserServicePath and getNemoclawGatewayEnvFilePath, then invoke
runSystemctlUser(["daemon-reload"], { env, spawnSyncImpl }) after both
deletions.
| try { | ||
| fs.rmSync(getNemoclawGatewayUserServicePath(opts), { force: true }); | ||
| } catch {} | ||
| try { | ||
| fs.rmSync(getNemoclawGatewayEnvFilePath(opts), { force: true }); | ||
| } catch {} |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Do not let the unit test delete real user-service files.
The new test injects existsSync: () => true, so these direct fs.rmSync calls remove files beneath the developer’s actual home directory. Inject rmSync alongside spawnSyncImpl and assert the requested paths instead.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/lib/onboard/docker-driver-gateway-service.ts` around lines 125 - 130,
Update the test setup around the cleanup calls in the relevant onboarding test
to inject an rmSync mock alongside spawnSyncImpl, and replace direct fs.rmSync
usage with that injected dependency. Assert that rmSync receives the gateway
service and environment-file paths with force enabled, ensuring no real
user-service files are deleted.
PR Review Advisor — Blocking findings reportedAdvisor assessment: Blockers require maintainer review Model lanes
Nemotron output stays in workflow artifacts and does not change the assessment above. E2E guidanceAdvisory only. E2E / PR Gate selects and runs jobs independently. Recommended E2E: Blockers
|
Summary
Implemented reboot persistence for the OpenShell gateway by adding a NemoClaw-managed systemd user service, environment handling, and related tests.
Related Issue
Fixes #6903
Changes
nemoclaw-openshell-gateway.serviceunit in user systemd config.DCO
Signed-off-by: Jibin7Jose [email protected]