Repository navigation
fix: clean final gateway failure state after diagnostics - #3018
Conversation
Signed-off-by: Aaron Erickson <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA new exported helper, ChangesGateway Failure Handler Extraction
Sequence DiagramsequenceDiagram
participant Start as startGatewayWithOptions
participant Handler as handleFinalGatewayStartFailure
participant Doctor as "openshell doctor (logs)"
participant Gateway as cleanupGateway / destroyGateway
participant Logger as printError
participant Process as exitProcess
Start->>Handler: call with { retries }
Handler->>Logger: print failure header & attempt info
Handler->>Doctor: collectDiagnostics()
Doctor-->>Handler: diagnostics (or throws)
Handler->>Gateway: cleanupGateway() (best-effort)
Gateway-->>Handler: cleanup result (or error)
Handler->>Logger: print redacted diagnostics + remediation commands
Handler->>Process: exitProcess(1)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@src/lib/onboard.ts`:
- Around line 2594-2597: The diagnostics probe assigned to collectDiagnostics
can hang and block the final failure path in handleFinalGatewayStartFailure;
wrap the runCaptureOpenshell(["doctor", "logs", "--name", GATEWAY_NAME], {
ignoreError: true }) call in a bounded timeout (e.g., Promise.race with a
setTimeout rejection/resolution or use an existing runWithTimeout helper) so the
probe is abandoned after a short configurable interval, returning/throwing a
timeout result that lets handleFinalGatewayStartFailure continue to call
destroyGateway() and exitProcess(1); update collectDiagnostics to return the
timed wrapper and include a descriptive timeout error or fallback value so
downstream logic handles it safely.
- Around line 2635-2640: Update the fallback recovery printouts to be portable
and use the CLI helper: replace the GNU-specific `xargs -r` invocation with a
POSIX-friendly form such as `xargs -I {} docker volume rm {}` so macOS/BSD xargs
works, and replace the hardcoded `nemoclaw` with the existing cliName() helper;
modify the printError calls that reference GATEWAY_NAME and the CLI invocation
(the lines building the docker volume removal command and the `nemoclaw onboard
--resume` line) to use `GATEWAY_NAME` and `cliName()` respectively.
🪄 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: d09e91c8-0efc-4c23-bf36-c8270e961280
📒 Files selected for processing (2)
src/lib/onboard.tstest/gateway-final-failure-cleanup.test.ts
| printError(" If gateway cleanup did not complete, run:"); | ||
| printError(` openshell gateway destroy -g ${GATEWAY_NAME}`); | ||
| printError( | ||
| ` docker volume ls -q --filter "name=openshell-cluster-${GATEWAY_NAME}" | xargs -r docker volume rm`, | ||
| ); | ||
| printError(` nemoclaw onboard --resume`); |
There was a problem hiding this comment.
Make the printed recovery commands portable and brand-aware.
Line 2638 uses GNU-only xargs -r, which fails on macOS, and Line 2640 hardcodes nemoclaw instead of the existing cliName() helper. Since this is the fallback recovery path, the commands need to work as printed.
Suggested fix
printError(" If gateway cleanup did not complete, run:");
printError(` openshell gateway destroy -g ${GATEWAY_NAME}`);
- printError(
- ` docker volume ls -q --filter "name=openshell-cluster-${GATEWAY_NAME}" | xargs -r docker volume rm`,
- );
- printError(` nemoclaw onboard --resume`);
+ printError(
+ ` volumes="$(docker volume ls -q --filter "name=openshell-cluster-${GATEWAY_NAME}")"; [ -z "$volumes" ] || docker volume rm $volumes`,
+ );
+ printError(` ${cliName()} onboard --resume`);🤖 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.ts` around lines 2635 - 2640, Update the fallback recovery
printouts to be portable and use the CLI helper: replace the GNU-specific `xargs
-r` invocation with a POSIX-friendly form such as `xargs -I {} docker volume rm
{}` so macOS/BSD xargs works, and replace the hardcoded `nemoclaw` with the
existing cliName() helper; modify the printError calls that reference
GATEWAY_NAME and the CLI invocation (the lines building the docker volume
removal command and the `nemoclaw onboard --resume` line) to use `GATEWAY_NAME`
and `cliName()` respectively.
There was a problem hiding this comment.
Thanks. I am leaving this one unchanged in this PR because the implementation prompt explicitly required the fallback guidance to use nemoclaw, openshell gateway destroy -g nemoclaw, and docker volume ls -q --filter "name=openshell-cluster-nemoclaw" | xargs -r docker volume rm. I agree the BSD/GNU portability point is real; changing that command contract would be a separate decision from this scoped cleanup fix.
There was a problem hiding this comment.
@ericksoa Got it — thanks for clarifying the prompt constraint. I’ll leave this unchanged for this PR.
If you’d like, I can open a follow-up issue to track:
- Replace hardcoded “nemoclaw” with cliName() in recovery guidance.
- Make the docker volume removal line portable across GNU/BSD (avoid xargs -r).
- Add a brief note in docs/tests to cover macOS portability.
Want me to create that issue and assign it to you?
🧠 Learnings used
Learnt from: jyaunches
Repo: NVIDIA/NemoClaw PR: 2495
File: src/lib/onboard-inference-probes.ts:135-323
Timestamp: 2026-04-27T13:06:57.456Z
Learning: In NVIDIA/NemoClaw PRs that extract code from `src/lib/onboard.ts` into new behavior-preserving modules (e.g., `src/lib/onboard-providers.ts`, `src/lib/onboard-ollama-proxy.ts`, `src/lib/onboard-inference-probes.ts`), reviewers should avoid requesting refactors/complexity/style improvements in the extracted modules as part of the same PR. Only check for correctness and behavior preservation; defer non-behavior-preserving cleanup to separate follow-up PRs.
Learnt from: ericksoa
Repo: NVIDIA/NemoClaw PR: 2554
File: src/lib/onboard.ts:698-700
Timestamp: 2026-04-28T17:22:19.715Z
Learning: For NVIDIA/NemoClaw credential environment hydration/migration, implement fill-only-if-missing semantics across the onboarding and credentials modules: (1) In src/lib/credentials.ts, stageLegacyCredentialsToEnv() should only consider an allowlisted set of credential keys and should set process.env[key] only when getCredential(key) returns null (never override an explicitly provided env export). Treat blank/whitespace values as unset. (2) In src/lib/onboard.ts, hydrateCredentialEnv(envName) must first read getCredential(envName) and only call stageLegacyCredentialsToEnv() when that specific key is missing; after staging, re-read and then set process.env[envName]. This ensures stale credentials.json values cannot override explicitly provided environment credentials.
Signed-off-by: Aaron Erickson <[email protected]>
Summary
destroyGateway()before exiting the exhausted-retry path.nemoclawgateway if cleanup still needs help.Tests
npm run build:clinpm run typecheck:clinpx vitest run test/gateway-final-failure-cleanup.test.ts test/gateway-cleanup.test.tsSupersedes #2280. Addresses the remaining cleanup gap from #17.
Summary by CodeRabbit
Bug Fixes
Tests