fix(backup-all): catch per-sandbox errors to avoid aborting the batch - #5740
fix(backup-all): catch per-sandbox errors to avoid aborting the batch#5740kagura-agent wants to merge 1 commit into
Conversation
|
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 (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthrough
ChangesPer-sandbox error isolation in
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
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 unit tests (beta)
Comment |
|
✨ Thanks for catching per-sandbox errors in the backup-all loop so a single missing agent manifest no longer aborts the entire batch. This proposes a way to wrap each backupSandboxState() call in try/catch, log a warning, increment a skipped counter, and continue processing remaining sandboxes. Related open issues: |
When loadAgent() throws for a sandbox whose agent manifest is missing (e.g. an orphan from a previous higher-version install), the exception now gets caught inside the backup loop. The affected sandbox is counted as 'skipped' with a warning, and the remaining sandboxes continue to be backed up normally. This allows the pre-upgrade backup step to succeed and the installer to proceed. Closes NVIDIA#5734 Signed-off-by: kagura-agent <kagura.agent.ai@gmail.com>
6b5685e to
ea758d5
Compare
|
Hi @kagura-agent, opened #5819 with a narrower version of this fix. The broad catch in this PR also swallows real backup failures (disk full, SSH timeout, permission denied) and would let the installer march forward with a corrupt or absent backup. #5819 only catches the exact orphan-manifest error pattern from |
… failures (#5819) ## Summary Catches the `loadAgent()` orphan-manifest case from #5734 so the pre-upgrade backup loop survives a sandbox whose agent manifest is missing, **without** silently swallowing real failures (disk full, SSH timeout, permission denied, programming bugs) the way #5740's broad catch did. ## Related Issue Closes #5734. **Supersedes #5740**. ## Why a new PR #5740 (kagura-agent) implemented the right outcome with a broad try/catch that swallowed every error and counted it as 'skipped', then exited 0. That lets the installer march forward with an upgrade after a real disk-full or SSH-timeout failure, and the restore path later reads a manifest pointing at a corrupt or absent backup. Data loss scenario. That PR is on a fork I cannot push to, so this is a fresh PR on the NVIDIA upstream so the PR Advisor and full CI run. ## Changes - `src/lib/actions/maintenance.ts`: narrow try/catch on `backupSandboxState()` that only matches the exact orphan-manifest pattern (`Agent '...' not found`) thrown by `loadAgent()` at `src/lib/agent/defs.ts:367`. Anything else re-throws so the installer aborts as it did before any wrapping existed. - `src/lib/actions/maintenance.test.ts`: new test file with 3 cases: - Orphan manifest in one sandbox does not abort the batch - Orphan manifest is counted as `skipped`, not `failed` - **Non-orphan errors (e.g. EACCES) are re-thrown so the installer aborts the upgrade** ## Verification - `npx vitest run src/lib/actions/maintenance.test.ts` — 3/3 pass - The narrow regex `/^Agent '[^']*' not found/` matches the exact error shape from `loadAgent` at `defs.ts:367` ## Type of Change - [x] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved batch backup reliability: if a sandbox fails due to a missing/orphan agent manifest (matching the expected “not found: <path>…manifest.yaml” pattern), the batch now logs a warning, marks the sandbox as skipped, updates counters, and continues processing remaining sandboxes. * Non-matching or unrecoverable errors still abort the batch as before. * **Tests** * Expanded maintenance test coverage for partial success/continuation, skipped behavior, and correct abort behavior for non-matching “not found” cases. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Charan Jagwani <cjagwani@nvidia.com>
… failures (NVIDIA#5819) ## Summary Catches the `loadAgent()` orphan-manifest case from NVIDIA#5734 so the pre-upgrade backup loop survives a sandbox whose agent manifest is missing, **without** silently swallowing real failures (disk full, SSH timeout, permission denied, programming bugs) the way NVIDIA#5740's broad catch did. ## Related Issue Closes NVIDIA#5734. **Supersedes NVIDIA#5740**. ## Why a new PR NVIDIA#5740 (kagura-agent) implemented the right outcome with a broad try/catch that swallowed every error and counted it as 'skipped', then exited 0. That lets the installer march forward with an upgrade after a real disk-full or SSH-timeout failure, and the restore path later reads a manifest pointing at a corrupt or absent backup. Data loss scenario. That PR is on a fork I cannot push to, so this is a fresh PR on the NVIDIA upstream so the PR Advisor and full CI run. ## Changes - `src/lib/actions/maintenance.ts`: narrow try/catch on `backupSandboxState()` that only matches the exact orphan-manifest pattern (`Agent '...' not found`) thrown by `loadAgent()` at `src/lib/agent/defs.ts:367`. Anything else re-throws so the installer aborts as it did before any wrapping existed. - `src/lib/actions/maintenance.test.ts`: new test file with 3 cases: - Orphan manifest in one sandbox does not abort the batch - Orphan manifest is counted as `skipped`, not `failed` - **Non-orphan errors (e.g. EACCES) are re-thrown so the installer aborts the upgrade** ## Verification - `npx vitest run src/lib/actions/maintenance.test.ts` — 3/3 pass - The narrow regex `/^Agent '[^']*' not found/` matches the exact error shape from `loadAgent` at `defs.ts:367` ## Type of Change - [x] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved batch backup reliability: if a sandbox fails due to a missing/orphan agent manifest (matching the expected “not found: <path>…manifest.yaml” pattern), the batch now logs a warning, marks the sandbox as skipped, updates counters, and continues processing remaining sandboxes. * Non-matching or unrecoverable errors still abort the batch as before. * **Tests** * Expanded maintenance test coverage for partial success/continuation, skipped behavior, and correct abort behavior for non-matching “not found” cases. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Charan Jagwani <cjagwani@nvidia.com>
Summary
When
loadAgent()throws for a sandbox whose agent manifest is missing (e.g. an orphan from a previous higher-version install), the exception now gets caught inside the backup loop. The affected sandbox is counted as skipped with a warning, and the remaining sandboxes continue to be backed up normally.This allows the pre-upgrade backup step to succeed and the installer to proceed — the upgrade itself would re-introduce the missing agent manifest.
Changes
src/lib/actions/maintenance.ts: WrapbackupSandboxState()call in try/catch. On throw, log a warning and incrementskippedcounter instead of crashing the loop.src/lib/actions/maintenance.test.ts(new): Unit tests verifying the loop continues after a throw, and the thrown sandbox is counted as skipped (not failed).Testing
vitest run— agent/defs, global actions, snapshot, domain/maintenance)tsc --noEmit)Closes #5734
Summary by CodeRabbit