Repository navigation
Grow detached Firecracker volumes (POST /volumes/{id}/resize) - #83
Conversation
Decision: Findings
Tests Run
Raw runtime output was retained in local Gitmoot state and is not posted here. |
… growth against the budget
|
Addressing review local-review-review-router-18e4c53209eaa8b4-1 (changes_requested at c36d154) at b96aebf. P1 (tools outlive a killed daemon): the grow now takes an exclusive flock on the disk and passes that open file to e2fsck and resize2fs (inherited fd), so the lock lives as long as the last tool. volumeInUse (attach, delete, backup, grow) probes the lock, independent of process memory. Probe on real tools: SIGKILL of the process mid-resize2fs left the tool running, a fresh process saw EWOULDBLOCK, then the lock cleared when the tool exited with the fs fully grown (49152 blocks). Tests: TestFirecrackerVolumeGrowFencedByDiskLock (in-memory reservation cleared, attach/delete/backup/grow all busy), TestLinuxHostResizeToolsKeepDiskLocked (real host, lock held by the tool after the parent descriptor closes). P2 (failed record publication released capacity): budget accounting (create, restore, grow) now counts each volume at max(record, disk file size); a retry no longer double counts. TestFirecrackerVolumeGrowFailedRecordKeepsBudget. Mutants all red: no flock probe, tools not inheriting the lock, record-size-only accounting. go vet and go test -race ./... pass. Still not verified: real Firecracker end to end. |
Decision: Findings
Tests Run
Raw runtime output was retained in local Gitmoot state and is not posted here. |
|
Addressing the P2 from review local-review-review-router-18e4c73f7724104d-1 (b96aebf) at 3683edc: in-flight growth was charged twice (extended disk file via max(record, file) plus the reserved growth). The grow reservation now carries (GrowFrom, GrowTo) and reserves only the not yet extended remainder; the extended part counts once through the disk file. TestFirecrackerVolumeGrowInFlightChargedOnce: budget 320, volume 128 growing to 192, a 128 MiB create is admitted during the grow and a further one refused; the old reservation turns it red (256 of 320 used, create refused). The reviewer confirmed the earlier P1 (flock fence) and P2 (unrecorded growth) fixes. go vet and go test -race ./... pass. Real Firecracker end to end still not verified. |
Decision: Findings
Tests Run
Raw runtime output was retained in local Gitmoot state and is not posted here. |
|
Addressing the P2 from review local-review-review-router-18e4c8ad017262b2-1 (3683edc, which also confirmed the P1/P2/P2 fixes) at 35efbc3: Truncate is sparse, so the grow's physical space is only used while the tools run, yet the disk-floor check dropped the growth once the file reached its size. reservedVolumeMiB now returns two figures: budget (restores plus the not yet extended part of a grow; the extended part counts through the footprint) and headroom (restores plus each grow's WHOLE growth until it ends); the three disk-floor checks use headroom, the budget sums use budget. TestFirecrackerVolumeGrowKeepsDiskHeadroom: with the file already extended, a create that would eat 1 MiB of the grow's headroom is refused, one that leaves it is admitted; clamping headroom to the unextended remainder turns it red. go vet and go test -race ./... pass. Real Firecracker end to end still not verified. |
Decision: Findings
Tests Run
Raw runtime output was retained in local Gitmoot state and is not posted here. |
|
Independent exact-head review APPROVED at 35efbc3: g7-review job local-review-review-router-18e4cabe5c753cd9-1, evidence=executed, no new findings. Four findings across three review rounds, all answered by executed probes: P1 filesystem tools outliving a killed daemon (flock inherited by the tools; attach/delete/backup/grow busy while held; real SIGKILL scenario), P2 unrecorded growth released from the budget, P2 in-flight growth charged twice, P2 sparse-file disk-floor headroom released early. Reviewer ran build, vet, focused regressions, race checks, the full VM suite and independent native-ext4 scenarios. Implementer was the sandboxd seat (same model family as reviewer disclosed). Both CI jobs pass; level3_required rechecked at this head. Merging with an exact-head guard under the existing assignment. Not verified: a real Firecracker volume end to end with the daemon (attach after grow, guest seeing the larger filesystem); no shared deployment. |
Requested by Deimos Forge (msg 392524; owner epic jerryfane/deimos-forge#1/#7): existing volumes (e.g. 4096 MiB) must grow to 10 GiB without hand-editing records.
API.
POST /volumes/{id}/resize {"sizeMiB":N}, control API key (operator route like backup; not reachable with sandbox envd tokens) ->200 {volumeID,name,sizeMiB}. Never shrinks (400), same size is a no-op, attached/busy 409, unknown 404, over budget or below the disk floor 400 (only the growth counts), drivers without the capability 501.Driver. Under volumeMu: read record, volumeInUse, trusted e2fsck/resize2fs (found at call time, so workers that never grow need nothing new), budget + free-disk floor for the growth, then reserve like an in-flight restore (blocks attach/delete/backup/second grow and counts against budget). Unlocked: extend the disk file,
e2fsck -f -p,resize2fs, then replace the record by atomic rename. A failed e2fsck truncates the file back (nothing resized). A crash or failed resize2fs leaves disk larger than record; repeating the same request completes it (a disk larger than the request is refused, never cut). Stale*.json.tmpremoved at startup.Risk to accept. e2fsck/resize2fs run as root on a filesystem the guest wrote: the first place the host parses guest-controlled metadata (mke2fs only writes a fresh fs; nothing is mounted). Documented in docs/firecracker.md. If that is not acceptable, the alternative is a guest-side grow at attach time (guest agent + image change), which this PR does not do.
Evidence (seat, local, Go 1.26.10). go vet and
go test -race ./...pass. New tests: grow/refusals/retry-after-failure/hold-during-grow/fsck-rollback in internal/vm, API behavior + 501 in internal/control. Mutants: removing the reservation turns TestFirecrackerVolumeGrowHoldsVolume red; removing the fsck rollback turns TestFirecrackerVolumeGrowFsckFailureRestoresDisk red. A third mutant (disable the explicit shrink check) stays green because growDisk also refuses a disk larger than the target: equivalent, not a gap. Real tools smoke (outside the driver, host.ResizeVolume with Debian e2fsprogs 1.47.0): 128 MiB ext4 holding a file -> 192 MiB, 49152 blocks, file readable, e2fsck clean; a filesystem with trashed group descriptors -> e2fsck exit 4, refused, filesystem unresized.Not verified. An end-to-end grow on a real Firecracker volume with the daemon, attach after grow, and the guest seeing the larger filesystem. Forge plans to test on its throwaway instance first. No deployment.