fix(recovery): retry state backup after restart - #8787
Conversation
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
📝 WalkthroughWalkthroughLegacy sandbox recreation now retries temporary unreachable state-backup failures. Each retry removes the partial manifest and waits two seconds. The retry limit and sleep behavior are injectable and covered by tests. ChangesSandbox relaunch retry
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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/actions/sandbox/supervisor-relaunch.test.ts`:
- Around line 162-190: Update the test “retries only transport-level state
backup failures after a container restart” to record dependency events from
backupState, removeBackup, sleep, and recreate, then assert the exact sequence:
initial backupState, removeBackup, sleep, retry backupState, and recreate.
Preserve the existing outcome assertions while verifying partial-backup cleanup
occurs before retrying.
In `@src/lib/actions/sandbox/supervisor-relaunch.ts`:
- Around line 35-36: Update the retry logic around backupState and
STATE_BACKUP_MAX_ATTEMPTS so the initial backup failure receives five additional
retries, allowing attempts 1 through 5; align the constant’s meaning with the
loop boundary. Add a boundary test covering five failed retries followed by a
successful result.
🪄 Autofix
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: df90ad20-1d4b-42ad-ac4e-7b0a1ce3a265
📒 Files selected for processing (2)
src/lib/actions/sandbox/supervisor-relaunch.test.tssrc/lib/actions/sandbox/supervisor-relaunch.ts
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
PR Review Advisor — InformationalAdvisor assessment: Informational / low confidence Model lanes
Second-opinion terminology and E2E selections are advisory. Live E2E does not run automatically for pull requests. 3 semantic terminology decisionsTerminology decisions are advisory. They affect the assessment only when a separate finding identifies concrete semantic impact.
E2E guidanceAdvisory only. A maintainer can dispatch the default E2E suite for the commit under review. Recommended E2E: None Manual-only E2E: 1 warning · 0 suggestionsWarningsWarnings do not block.
|
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Security review: PASSReviewed the complete PR diff through branch revision Review checklist
Verification
No security findings or security-review blocker remain for this branch revision. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/actions/sandbox/supervisor-relaunch.test.ts`:
- Around line 200-233: Strengthen the test around
relaunchManagedSupervisorSession by recording events in the backupState,
removeBackup, sleep, and recreate fakes, then assert the full retry ordering:
each of the five failed backupState calls is followed by removal of its partial
manifest and sleep(2), the sixth backup succeeds, and recreate runs afterward.
Retain the existing outcome assertions while replacing call-count-only coverage
with behavioral sequence checks.
🪄 Autofix
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: 6d7baa27-3838-4a48-9b01-019e99dab179
📒 Files selected for processing (2)
src/lib/actions/sandbox/supervisor-relaunch.test.tssrc/lib/actions/sandbox/supervisor-relaunch.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/lib/actions/sandbox/supervisor-relaunch.ts
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Security review refresh: PASSReviewed the complete PR diff through branch revision The test now records all backup, partial-backup removal, fixed two-second wait, and recreation events. It proves that each of the five failed backup calls is cleaned up before waiting, the sixth backup succeeds, and container recreation occurs only afterward. This strengthens the fail-closed filesystem and sandbox-transaction evidence without adding runtime input, credentials, network access, privileges, dependencies, logging, or unbounded work. Verification remains green locally: 18/18 focused tests, formatting, CLI type-check, test-size, repository hooks, commit-message, and pre-push checks passed. All four commits are signed and appear as Verified in GitHub. The complete diff is 2 files, +155/-1, so no large-LOC flag applies. No security findings or security-review blocker remain for this branch revision. |
|
Post-merge CI classification: repository lifecycle/infrastructure, not a PR code failure. All 12 CLI test shards passed. The final No branch rerun is useful now that the PR is closed. The integrated revision remains subject to the normal |
Summary
Legacy supervisor recovery currently performs a one-shot state backup immediately after Docker restart, when OpenShell exec can be ready before its SSH transport. Retry only that typed transport lag before recreation while keeping integrity, audit, and cleanup failures terminal.
Changes
unreachablestate backups up to five attempts with a two-second container-side wait.Type of Change
Quality Gates
Documentation Writer Review
no-docs-neededdocs/manage-sandboxes/recover-rebuild-sandboxes.mdxanddocs/manage-sandboxes/backup-restore.mdx; the bounded transport retry does not change supported state, commands, settings, final failure handling, or the recovery acceptance criterion. Documentation validation passed with 0 errors and 2 existing warnings.DGX Station Hardware Evidence
Verification
Signed-off-by:line and every commit appears asVerifiedin GitHubpre-commit,commit-msg, andpre-pushhooks passed, ornpm run validate:prpassed after refreshingorigin/mainwhen hooks were skipped or unavailablenpm testfor broad runtime/test-harness changes;npm run checkfor repo-wide validation/coverage changes — command/result: Not applicable; focused recovery boundary with targeted unit and integration coverage.npm run docsbuilds without warnings (doc changes only)Signed-off-by: Apurv Kumaria akumaria@nvidia.com
Summary by CodeRabbit
Bug Fixes
Tests