Repository navigation
Add nemoclaw_clean.sh to free ports 8080 and 18789 before re-onboarding - #399
sayalinvidia wants to merge 2 commits into
Conversation
📝 WalkthroughWalkthroughAdds an executable Bash script ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment Tip CodeRabbit can suggest fixes for GitHub Check annotations.Configure the |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@nemoclaw_clean.sh`:
- Line 2: Replace the current shell option "set -e" with a combination that
enables pipefail so failures in pipeline stages (e.g., the lsof pipeline and the
"openshell forward list" pipeline) are not ignored; specifically update the
options to "set -e -o pipefail" (or "set -eo pipefail") at the top of the script
to ensure any failing command in a pipeline causes the script to fail and
trigger cleanup handling.
- Around line 10-13: The forward-cleanup silently hides failures and assumes a
stable column layout; add an upfront check for openshell (e.g., command -v
openshell) and fail loudly if missing, remove the global stderr suppression
(delete 2>/dev/null) so errors from openshell propagate, capture the output of
openshell forward list into a variable, validate it is non-empty before parsing,
and then parse lines more defensively (replace awk 'NR>1 {print $1, $2}' with a
check that each line contains both port and sandbox before calling openshell
forward stop "$port" "$sandbox"); keep the existing conditional that only stops
port 18789 but log or exit if openshell forward list fails.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 40e25594-3371-4c0b-bdcb-f36c288f71c8
📒 Files selected for processing (1)
nemoclaw_clean.sh
| @@ -0,0 +1,14 @@ | |||
| #!/usr/bin/env bash | |||
| set -e | |||
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -e
echo "Checking shell safety flags and pipeline usage in nemoclaw_clean.sh"
rg -n '^\s*set\s+-' nemoclaw_clean.sh
rg -n '\|' nemoclaw_clean.sh
python - <<'PY'
from pathlib import Path
text = Path("nemoclaw_clean.sh").read_text()
print("has_pipeline:", "|" in text)
print("has_pipefail:", "pipefail" in text)
if "|" in text and "pipefail" not in text:
print("Potential masked pipeline failures detected.")
PYRepository: NVIDIA/NemoClaw
Length of output: 373
🏁 Script executed:
cat nemoclaw_clean.shRepository: NVIDIA/NemoClaw
Length of output: 452
Enable pipefail so cleanup failures aren't silently ignored.
At Line 2, set -e alone does not catch failures in earlier pipeline stages (used at Line 6 and Line 10). Without pipefail, if lsof or openshell forward list fails, the script continues silently, leaving ports/forwards potentially uncleaned.
Proposed fix
- set -e
+ set -euo pipefail📝 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.
| set -e | |
| set -euo pipefail |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@nemoclaw_clean.sh` at line 2, Replace the current shell option "set -e" with
a combination that enables pipefail so failures in pipeline stages (e.g., the
lsof pipeline and the "openshell forward list" pipeline) are not ignored;
specifically update the options to "set -e -o pipefail" (or "set -eo pipefail")
at the top of the script to ensure any failing command in a pipeline causes the
script to fail and trigger cleanup handling.
| openshell forward list 2>/dev/null | awk 'NR>1 {print $1, $2}' | while read port sandbox; do | ||
| if [ "$port" = "18789" ]; then | ||
| openshell forward stop "$port" "$sandbox" | ||
| fi |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
For the OpenShell CLI docs: does openshell forward list support a machine-readable output mode (e.g., --json/--format), and is the default table column order guaranteed/stable?
💡 Result:
I couldn’t find any official/public “OpenShell CLI” documentation pages that mention the openshell forward list command at all (nor any --json / --format flag for it), so I can’t confirm a machine-readable output mode or any guarantee of a stable/default table column order from docs. The only “--json” CLI doc I found was for a different project (“OpenHands”), not “openshell forward list.” (docs.openhands.dev)
If you share the URL of the OpenShell CLI docs you’re looking at (or the openshell forward list --help output), I can answer definitively from that source.
Citations:
🏁 Script executed:
fd -t f "nemoclaw_clean.sh" -x wc -l {}Repository: NVIDIA/NemoClaw
Length of output: 81
🏁 Script executed:
fd -t f "nemoclaw_clean.sh" -x cat -n {}Repository: NVIDIA/NemoClaw
Length of output: 550
🏁 Script executed:
find . -type f -name "*.sh" | head -20Repository: NVIDIA/NemoClaw
Length of output: 499
🏁 Script executed:
rg "openshell" -t sh --max-count 20Repository: NVIDIA/NemoClaw
Length of output: 10287
Add upfront check for openshell availability; stop suppressing errors in forward cleanup.
At Line 10, 2>/dev/null hides failures (missing tool, auth issues, config problems), and the awk-based table parsing depends on undocumented column layout with no guaranteed stability. Unlike most other scripts in the repo (e.g., setup.sh, uninstall.sh), this code doesn't verify that openshell is installed before using it. This makes forward cleanup silently fail rather than report the problem.
Proposed fix
+if ! command -v openshell >/dev/null 2>&1; then
+ echo "openshell not found; skipping forward cleanup" >&2
+ exit 0
+fi
+
-openshell forward list 2>/dev/null | awk 'NR>1 {print $1, $2}' | while read port sandbox; do
+openshell forward list | awk 'NR>1 {print $1, $2}' | while read -r port sandbox; do
if [ "$port" = "18789" ]; then
openshell forward stop "$port" "$sandbox"
fi📝 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.
| openshell forward list 2>/dev/null | awk 'NR>1 {print $1, $2}' | while read port sandbox; do | |
| if [ "$port" = "18789" ]; then | |
| openshell forward stop "$port" "$sandbox" | |
| fi | |
| if ! command -v openshell >/dev/null 2>&1; then | |
| echo "openshell not found; skipping forward cleanup" >&2 | |
| exit 0 | |
| fi | |
| openshell forward list | awk 'NR>1 {print $1, $2}' | while read -r port sandbox; do | |
| if [ "$port" = "18789" ]; then | |
| openshell forward stop "$port" "$sandbox" | |
| fi | |
| done |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@nemoclaw_clean.sh` around lines 10 - 13, The forward-cleanup silently hides
failures and assumes a stable column layout; add an upfront check for openshell
(e.g., command -v openshell) and fail loudly if missing, remove the global
stderr suppression (delete 2>/dev/null) so errors from openshell propagate,
capture the output of openshell forward list into a variable, validate it is
non-empty before parsing, and then parse lines more defensively (replace awk
'NR>1 {print $1, $2}' with a check that each line contains both port and sandbox
before calling openshell forward stop "$port" "$sandbox"); keep the existing
conditional that only stops port 18789 but log or exit if openshell forward list
fails.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
docs/reference/troubleshooting.md (1)
97-102:⚠️ Potential issue | 🟡 MinorManual cleanup example is incomplete for dual-port conflicts.
Line 97 says conflicts can be on either port, but the example only checks Line 100 (
18789). Add8080too, otherwise users can miss the actual blocker.Suggested doc fix
**Manual cleanup:** Otherwise, identify the conflicting process, verify it is safe to stop, and terminate it: ```console -$ lsof -i :18789 +$ lsof -i :8080 +$ lsof -i :18789 $ kill <PID></details> <details> <summary>🤖 Prompt for AI Agents</summary>Verify each finding against the current code and only fix it if needed.
In
@docs/reference/troubleshooting.mdaround lines 97 - 102, The "Manual
cleanup" example only checks port 18789 but the text states conflicts can be on
either port; update the example under the "Manual cleanup" block to run lsof for
both ports (add lsof -i :8080 before or alongside lsof -i :18789) so users can
discover the actual blocking process, then use kill for the matched PID;
refer to the "Manual cleanup" heading and the port numbers 8080 and 18789 when
making the change.</details> </blockquote></details> </blockquote></details>🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed. Outside diff comments: In `@docs/reference/troubleshooting.md`: - Around line 97-102: The "Manual cleanup" example only checks port 18789 but the text states conflicts can be on either port; update the example under the "Manual cleanup" block to run lsof for both ports (add lsof -i :8080 before or alongside lsof -i :18789) so users can discover the actual blocking process, then use kill <PID> for the matched PID; refer to the "Manual cleanup" heading and the port numbers 8080 and 18789 when making the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID:
8e962d68-a87c-497b-ae7b-b04fed43075c📒 Files selected for processing (3)
README.mddocs/reference/troubleshooting.mdspark-install.md✅ Files skipped from review due to trivial changes (2)
- README.md
- spark-install.md
|
Thanks for putting this together and for pushing on a real usability problem. The Spark re-onboard failure mode is worth fixing, and I appreciate the effort to give users a concrete recovery path. I reviewed this against current Because of that, this PR doesn't appear to add a needed core fix on top of
So the closure here is about fix direction, not about the problem statement. If there is still a reproducible Spark issue on current Appreciate the contribution and the issue write-up. If you want to take another pass in that direction, I’d be happy to re-review it. |
Fixes #397
This adds a helper script
nemoclaw_clean.shto improve the DX when re-runningnemoclaw onboardon DGX Spark.This addresses repeated onboarding failures caused by lingering OpenShell
gateway / ssh-proxy processes that keep those ports occupied.
Summary by CodeRabbit
New Features
Documentation