Skip to content

fix(fc): make pause/resume real disk snapshots, not just a vCPU freeze - #981

Merged
cdalar merged 2 commits into
mainfrom
fc-pause-resume-snapshot
Jul 21, 2026
Merged

cdalar merged 2 commits into
mainfrom
fc-pause-resume-snapshot

Conversation

@cdalar

@cdalar cdalar commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • onctl pause's help text already promised "snapshot the VM's disk, preserve its IP, then delete the VM" — matching every other provider's cost-saving pause — but for the fc (Firecracker) provider it was only ever a live, in-memory vCPU freeze with the process left running. No disk snapshot was written, no compute was actually freed, and there was nothing portable to move a microVM to another host.
  • Pause now writes a full Firecracker snapshot (device state + guest memory, via /snapshot/create) into the VM's state directory, stops the firecracker process, and tears down its TAP device — genuinely no compute cost while paused, like every other provider.
  • Resume starts a fresh firecracker process and reloads it from that snapshot via /snapshot/load, remapping the TAP device through Firecracker's network_overrides (TAP devices are host-local and never survive a snapshot/restore).
  • Since a paused VM's state directory already holds its rootfs image alongside the new snapshot files, copying that directory to another host with an identically-configured StateDir and running onctl resume there is now enough to relocate a microVM — this was the actual motivating use case (portable snapshots of long-running fc microVMs).
  • Fixes a latent bug this surfaced: loadAndReconcile would have wrongly flipped paused VMs to "dead" now that pause legitimately stops their process (previously the process stayed alive, just frozen).

Test plan

  • go build ./...
  • go vet ./...
  • golangci-lint run ./pkg/cloud/... ./internal/providerfc/... — 0 issues
  • go test ./pkg/cloud/... ./internal/providerfc/... — pass, including new coverage for pause-when-not-alive, snapshot-create failure (rolls back to Resumed instead of leaving the VM stuck frozen), and resume with a missing snapshot file
  • go test ./... — pass except two pre-existing failures in ./cmd (TestReadConfig_NoConfigDirectory, TestCreateFlagsBindToViper) confirmed present on main before this change, unrelated
  • Manual pause/resume against a real firecracker binary (see TESTING-fc.md's existing sudo ONCTL_CLOUD=fc onctl pause mv2 && sudo ONCTL_CLOUD=fc onctl resume mv2), including copying a paused VM's state dir to a second host and resuming it there

🤖 Generated with Claude Code

Pause's doc comment promised a snapshot-then-delete (matching every other
provider's cost-saving pause), but for fc it was only ever a live,
in-memory vCPU freeze with the process left running — no snapshot, no
compute savings, and nothing portable to another host.

Pause now writes a full Firecracker snapshot (state + memory) to the VM's
state dir, stops the process, and tears down its TAP device. Resume starts
a fresh process and reloads it from that snapshot, remapping the TAP
device via Firecracker's network_overrides (TAP devices are host-local and
never survive a snapshot). Since the VM's state dir already holds its
rootfs image, copying it to another identically-configured host and
running `onctl resume` there is now enough to relocate a microVM.

Also fixes loadAndReconcile, which would have wrongly flipped paused VMs
to "dead" now that pause legitimately stops their process.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f8e046f75

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkg/cloud/fc.go Resolved
Comment thread pkg/cloud/fc.go Resolved
Address Codex review comments on PR #981: if saveFCMetadata fails
after Pause has already snapshotted and stopped the VMM, or after
Resume has already reloaded it, the on-disk record was left silently
stale, and a retried Resume could start a second competing process.
Resume now tears down the process/TAP it just started; Pause's error
now says explicitly that the snapshot is still usable.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KaxWizDbb5vGpa9uGaEKbD
@cdalar
cdalar merged commit bad44f0 into main Jul 21, 2026
13 checks passed
@cdalar
cdalar deleted the fc-pause-resume-snapshot branch August 19, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址