[PR #404] [CLOSED] fix: release snapshot filesystems before replacing volume drives #409

Closed
opened 2026-10-29 14:23:05 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/kvcache-ai/AgentENV/pull/404
Author: @Primary33
Created: 10/21/2026
Status: ❌ Closed

Base: main ← Head: fix/snapshot-volume-replacement


📝 Commits (1)

  • c5d84a9 fix: release snapshot filesystems before replacing volume drives

📊 Changes

21 files changed (+910 additions, -11 deletions)

View changed files

📝 docs/src/concepts/sandboxes/starting.md (+9 -0)
📝 docs/src/concepts/volumes/sandbox-forks-and-snapshots.md (+6 -0)
📝 src/api/generated/src/models.rs (+2 -0)
📝 src/api/impls/image_build/worker.rs (+1 -0)
📝 src/api/impls/sandbox.rs (+69 -2)
📝 src/api/impls/volumes.rs (+127 -0)
📝 src/api/openapi.yml (+12 -0)
📝 src/orchestrator/service.rs (+3 -0)
📝 src/orchestrator/tests.rs (+19 -0)
📝 src/orchestrator/types.rs (+3 -0)
📝 src/sandbox/firecracker/resources.rs (+13 -0)
📝 src/sandbox/firecracker/sandbox.rs (+239 -6)
📝 src/sandbox/guest_volumes.rs (+102 -2)
📝 src/sandbox/mock.rs (+7 -1)
📝 src/sandbox/mod.rs (+5 -0)
📝 src/volume/mod.rs (+15 -0)
📝 tests/integration.rs (+3 -0)
📝 tests/integration/orchestrator.rs (+3 -0)
📝 tests/integration/posix_startup_pack.rs (+1 -0)
📝 tests/integration/snapshot.rs (+2 -0)

...and 1 more files

📄 Description

What

Safely replace snapshot volume mounts, including empty arrays, changed paths, and read-only/writable transitions.

Why

Rebinding a drive while the guest retains its old filesystem can reuse a live superblock and cached data against a different disk, risking corruption.

Identified while implementing #398. This fix branches directly from main.

Design and behavior changes

  • Load captured volume layers through disposable drives in their original slots, protected from startup cache GC.
  • After envd initialization, unmount without lazy detach and verify that old ext4 superblocks and mounts across guest processes are gone before PATCHing the slots.
  • Mount the replacement drives, restore unused slots to placeholders, and immediately release staging devices. Teardown handles failed launches.

Compatibility and operations

Explicit replacement now returns HTTP 409 when captured processes or mount aliases retain an old filesystem. Close files, move process working directories off volumes, and remove aliases before recapturing affected templates. The snapshot format is unchanged.

Validation

Run on Ubuntu 24.04 with non-root test processes and isolated state:

  • make agentenv-server, make fmt, make clippy.
  • make test-unit: 1210 passed; CLI tests run serially.
  • cargo test -p agentenv --lib: 1021 passed.
  • Rust integration suites: 24 passed; 1 startup-pack test ignored because its required configuration is disabled.
  • OSS E2E: 9 passed using isolated Docker.
  • API E2E: 12 scenario groups passed, covering both create endpoints, mount counts/paths/modes, pause/resume, capture, fork, busy 409 rollback, immutable snapshot layers, and device cleanup.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/kvcache-ai/AgentENV/pull/404 **Author:** [@Primary33](https://github.com/Primary33) **Created:** 10/21/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/snapshot-volume-replacement` --- ### 📝 Commits (1) - [`c5d84a9`](https://github.com/kvcache-ai/AgentENV/commit/c5d84a967ffb14beaa78ec09f76fe83badf2c5fc) fix: release snapshot filesystems before replacing volume drives ### 📊 Changes **21 files changed** (+910 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `docs/src/concepts/sandboxes/starting.md` (+9 -0) 📝 `docs/src/concepts/volumes/sandbox-forks-and-snapshots.md` (+6 -0) 📝 `src/api/generated/src/models.rs` (+2 -0) 📝 `src/api/impls/image_build/worker.rs` (+1 -0) 📝 `src/api/impls/sandbox.rs` (+69 -2) 📝 `src/api/impls/volumes.rs` (+127 -0) 📝 `src/api/openapi.yml` (+12 -0) 📝 `src/orchestrator/service.rs` (+3 -0) 📝 `src/orchestrator/tests.rs` (+19 -0) 📝 `src/orchestrator/types.rs` (+3 -0) 📝 `src/sandbox/firecracker/resources.rs` (+13 -0) 📝 `src/sandbox/firecracker/sandbox.rs` (+239 -6) 📝 `src/sandbox/guest_volumes.rs` (+102 -2) 📝 `src/sandbox/mock.rs` (+7 -1) 📝 `src/sandbox/mod.rs` (+5 -0) 📝 `src/volume/mod.rs` (+15 -0) 📝 `tests/integration.rs` (+3 -0) 📝 `tests/integration/orchestrator.rs` (+3 -0) 📝 `tests/integration/posix_startup_pack.rs` (+1 -0) 📝 `tests/integration/snapshot.rs` (+2 -0) _...and 1 more files_ </details> ### 📄 Description ## What Safely replace snapshot volume mounts, including empty arrays, changed paths, and read-only/writable transitions. ## Why Rebinding a drive while the guest retains its old filesystem can reuse a live superblock and cached data against a different disk, risking corruption. ## Related issue Identified while implementing #398. This fix branches directly from `main`. ## Design and behavior changes - Load captured volume layers through disposable drives in their original slots, protected from startup cache GC. - After envd initialization, unmount without lazy detach and verify that old ext4 superblocks and mounts across guest processes are gone before PATCHing the slots. - Mount the replacement drives, restore unused slots to placeholders, and immediately release staging devices. Teardown handles failed launches. ## Compatibility and operations Explicit replacement now returns HTTP 409 when captured processes or mount aliases retain an old filesystem. Close files, move process working directories off volumes, and remove aliases before recapturing affected templates. The snapshot format is unchanged. ## Validation Run on Ubuntu 24.04 with non-root test processes and isolated state: - `make agentenv-server`, `make fmt`, `make clippy`. - `make test-unit`: 1210 passed; CLI tests run serially. - `cargo test -p agentenv --lib`: 1021 passed. - Rust integration suites: 24 passed; 1 startup-pack test ignored because its required configuration is disabled. - OSS E2E: 9 passed using isolated Docker. - API E2E: 12 scenario groups passed, covering both create endpoints, mount counts/paths/modes, pause/resume, capture, fork, busy 409 rollback, immutable snapshot layers, and device cleanup. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 14:23:05 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kvcache-ai/AgentENV#409
No description provided.