Skip to content

feat: add the keep-snapshot-on-delete pod flag - #14

Merged
CMGS merged 3 commits into
mainfrom
feat/keep-snapshot-on-delete
Jul 31, 2026
Merged

feat: add the keep-snapshot-on-delete pod flag#14
CMGS merged 3 commits into
mainfrom
feat/keep-snapshot-on-delete

Conversation

@tonicmuroq

Copy link
Copy Markdown
Contributor

Why

A hibernatePolicy: release suspend deletes the pod to free its scheduling seat, while the VM state stays claimable from the :hibernate registry tag. But vk-cocoon's DeletePod cannot tell that deletion apart from a real teardown, so it GCs the node-local snapshot — and with it the only thing that would let a wake landing back on the same node skip the registry pull.

The wake path is otherwise already local-first: resolveWakeSource prefers a local snapshot and only pulls on a miss, and cleanupWakeImport explicitly keeps the local copy "live for the next wake". retain is fast today precisely because its pod is never deleted, so its snapshot is never GC'd. This flag gives release the same fast path without holding the seat.

What

  • AnnotationKeepSnapshotOnDelete = vm.cocoonstack.io/keep-snapshot-on-delete, plus ReadKeepSnapshotOnDelete / MarkKeepSnapshotOnDelete mirroring the restore-from-hibernate pair.
  • PatchKeepSnapshotOnDelete, following PatchHibernateState's short-circuit shape.

Additive only — nothing reads the flag until the operator and vk-cocoon PRs land.

Safety

Keeping the snapshot cannot resurrect stale state. verifyLocalSnapshot compares the local snapshot's ID against the SnapshotID in the hibernate tag's config blob and discards any mismatch; a missing tag is judged stale; an unreachable registry fails closed. The tag remains the sole authority, and the local copy is strictly a cache keyed by it.

Follow-up (not in this PR)

Nothing reclaims a kept snapshot today — vk's orphan policy covers VMs, not snapshots. Before this ships, node-level cocoon gc --snapshot --snapshot-size/-age needs to bound the cache, and vk's storage allocatable (read once at startup) needs to stop hiding it from the scheduler. Otherwise this trades silent disk oversubscription for memory oversubscription.

Test

go build ./..., go test ./..., make lint (linux + darwin) all green.

A hibernatePolicy=release suspend deletes the pod to free its scheduling
seat while the VM state stays claimable from the :hibernate tag. vk-cocoon
cannot tell that deletion apart from a real teardown, so it GCs the
node-local snapshot — and with it the only thing that would let a wake
landing back on the same node skip the registry pull.

This is the signal that tells them apart: the operator flags the pod just
before a seat-release delete, and vk-cocoon keeps the local snapshot as a
warm-wake cache. Read/Mark mirror the restore-from-hibernate pair, and
PatchKeepSnapshotOnDelete follows PatchHibernateState's short-circuit.

Keeping the snapshot cannot restore stale state: resolveWakeSource still
verifies any local copy against the SnapshotID in the tag's config blob
and discards a mismatch, so the tag stays the sole authority.
@CMGS
CMGS merged commit 9ca4f1c into main Jul 31, 2026
2 checks passed
@CMGS
CMGS deleted the feat/keep-snapshot-on-delete branch July 31, 2026 04:24
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