Repository navigation
fix(backup): clean up snapshots when native capture throws - #13010
Conversation
A strict pre-upgrade backup publishes its snapshot before capturing the policy and MCP recovery handoffs. When either capture threw, the command exited nonzero but left the new timestamped snapshot behind, even though it lacks the handoffs needed to restore after the historical gateway is retired. The MCP observation added in v0.0.128 made this path reachable. Remove the snapshot through the same path-confined cleanup used for failed strict backups, and report a cleanup failure alongside the original error. Fixes #12277 Signed-off-by: Arjun Ganesh <[email protected]>
Resolve the strict recovery conflicts using main's deferred cleanup and deadline handling. Preserve the original signed contribution in history. Keep the additional early-capture cleanup fix for a separate commit. Signed-off-by: Hung Le <[email protected]>
Remove the directory created by a failed capture while preserving the original error and earlier valid backups. Create the timestamp directory exclusively so a concurrent backup is not adopted for cleanup. Respect the existing cleanup deadline and report the retained path when removal cannot complete. Cover temporary-directory failure, denied cleanup, deadline expiry, and a competing backup writer through the native backup path. Refs #12277 Signed-off-by: Hung Le <[email protected]>
Code Coverage OverviewLanguages: TypeScript TypeScript / code-coverage/pluginThe overall line coverage in commit cd7ddde in the Show a line coverage summary of the most impacted files.
TypeScript / code-coverage/cliThe overall line coverage in commit cd7ddde in the Show a line coverage summary of the most impacted files.
Updated |
|
PR Review Advisor finished for commit Request review only when Require no Advisor blockers is green. |
sandl99
left a comment
There was a problem hiding this comment.
Reviewed commit cd7ddde. No actionable correctness or security findings.
The cleanup tracks the exclusively created backup directory, preserves the caller's deadline, and reports the retained path and original cause when removal fails.
Validation: 64/64 focused snapshot tests passed locally. Required CI and all nine Advisor specialist reports passed for this commit. CodeRabbit has no actionable findings. Live sandbox behavior and the original QA scenario were not independently verified.
Outcome
An exception during native backup capture no longer leaves its newly created timestamp directory behind when cleanup can complete. Earlier backups and a concurrent writer's backup remain intact. If cleanup fails or its deadline expires, the error identifies the retained path and preserves the original cause.
Reason
SSH temporary-directory allocation can fail after the timestamp directory is created, before a
BackupResultexists. Cleanup that relies on a returned result cannot see that directory.This PR carries forward Arjun Ganesh's contribution from #12329, retaining the original signed commit unchanged. Integration with
mainpreserves the later lifecycle cleanup from #12250. The remaining diff addresses exceptions during native capture.Related issues
Fixes #12277. Maintainer adoption of #12329.
Changes
Verification
The validated source and test bytes are committed as
cd7ddde7fa254bc57ad4b79e787810d723036af4; their hashes still match after commit hooks. Behavioral checks ran on DGX Linux aarch64, Node 22.23.3, with unchanged dependency locks and OpenShell SDK 0.0.116.0b0d699c3ac0cbe17a8938a9706f76e1b1a774ea, then passed with the fix.node node_modules/vitest/vitest.mjs run --project integration test/state/snapshot-backup-cleanup.test.ts test/state/snapshot.test.ts test/state/snapshot-native-deadline.test.ts test/state/snapshot-recovery-validation.test.ts: 63 of 64 passed initially. One existing test needed the plugin build artifact. Afternpm --prefix nemoclaw run build, the affectedsnapshot.test.tspassed all 47 tests; the other 17 passing results remain applicable.The tests create previous and competing snapshots through the native backup API, then compare manifest and archive bytes. A test executable supplies SSH configuration; cleanup denial and deadline expiry use controlled inputs. This covers the filesystem cleanup boundary without requiring a live sandbox.
The full suite and live sandbox tests were not run for this final revision. Earlier live results apply to the original contribution and its earlier repair. The original QA trigger and the historical regression boundary remain unverified.
Review notes
Keep this PR as a draft until CI and automated reviews for the updated commit have been evaluated. Results for the original adoption commit do not validate this repair.
Signed-off-by: Hung Le [email protected]
Summary by CodeRabbit