Repository navigation
Conversation
A full fork of a Firecracker sandbox with writable managed volumes sealed the volumes first (snapshot_volume_mounts, then resume), cloned the children's volumes from that seal, and only then paused again to capture memory. A child therefore resumed memory from the second pause on top of volumes from the first: writes in between were missing, and the guest's page cache and filesystem metadata no longer matched the disk. Fork now captures first and describes the children afterwards: - SandboxBackend::capture_fork returns a SandboxForkCapture that can spawn any number of children. Firecracker implements it with a single pause: pause_to_dir already restacks every writable persistent volume into its backing while the VM is paused, so memory, rootfs and volumes come from the same instant. Firecracker's one-step fork reuses the same path. - ForkChildren::AfterCapture hands the orchestrator a ForkChildPreparer. The orchestrator captures, lets the preparer clone the children's volumes from the backings the capture just sealed, then spawns the children. The preparer releases the volumes of children that fail. - The fork API routes sources with volumes through a VolumeForkPreparer and no longer seals volumes ahead of the fork. Volume errors keep their status codes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #557
Approach
Fork now captures first and describes the children afterwards.
SandboxBackend::capture_forkreturns aSandboxForkCapturethat canspawnany number of children.pause_to_dirplus resume.pause_to_diralready restacks writable persistent volumes into their backings while the VM is paused, so memory, rootfs and volumes are consistent.forkreuses this path.ForkChildren::{Ready, AfterCapture}in the orchestrator.AfterCapturecarries aForkChildPreparer. The order is capture, then the preparer clones volumes from the just-sealed backings, then spawn.VolumeForkPreparer. The separatesnapshot_volume_mountscall before the fork is removed. Volume errors keep their 404/409/500 mapping.fork.Tests
cargo clippy --all-targets -D warningsandcargo test --lib -p agentenv(1071 passed) pass.Not covered
No end-to-end run on a real Firecracker VM with volumes yet.
🤖 Generated with Claude Code