feat: cross-node migration (nodeName affinity + migration state machine)#11
Open
tonicmuroq wants to merge 2 commits into
Open
feat: cross-node migration (nodeName affinity + migration state machine)#11tonicmuroq wants to merge 2 commits into
tonicmuroq wants to merge 2 commits into
Conversation
buildAgentPod gives the main agent (slot 0) a required hostname nodeAffinity from spec.NodeName instead of a hard NodeName bind, so a migrate target that won't fit stays Pending rather than OOM-ing, and cordon is respected. Sub-agents keep their hard-bind to the main's node. Imports the updated CocoonSet CRD and bumps cocoon-common for the NodeName field.
Reconcile drives the main agent across nodes when spec.nodeName drifts from where the pod runs. reconcileMigration is a pure observation function over durable state (spec.nodeName, the pod, the epoch :hibernate snapshot): set the internal hibernate annotation -> wait for the snapshot -> delete the old pod -> recreate on the target with restore-from-hibernate -> wait for the restored VMID -> drop the snapshot. Idempotent and crash-recoverable; runs before applyUnsuspend so its hibernate annotation isn't cleared mid-flight. Ordering gates: old pod deleted only after the snapshot lands; snapshot dropped only after the new VM has a fresh VMID. Surfaces CocoonSetPhaseMigrating. Scoped to the main agent (one VM per CocoonSet). Bumps cocoon-common for the phase enum.
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.
Operator side of cross-node
migrate(vmname, node): the control plane patchesCocoonSet.spec.nodeName, the operator does the rest.What
buildAgentPod): the main agent (slot 0) gets a required hostnamenodeAffinityfromspec.nodeNameinstead of a hardNodeNamebind — it lands on the target only if it fits and the node is schedulable, else stays Pending (respects capacity/cordon, no OOM). Sub-agents keep their hard-bind to the main's node.reconcileMigration): a pure observation function over durable state (spec.nodeName, the pod, the epoch:hibernatesnapshot) — set internal hibernate annotation → wait for snapshot → delete old pod → recreate on target withrestore-from-hibernate→ wait for the restored VMID → drop the snapshot. Idempotent and crash-recoverable; runs beforeapplyUnsuspendso its hibernate annotation isn't cleared mid-flight. Ordering gates: old pod deleted only after the snapshot lands; snapshot dropped only after the new VM has a fresh VMID. SurfacesCocoonSetPhaseMigrating. Scoped to the main agent (one VM per CocoonSet).Dependency
Depends on cocoonstack/cocoon-common#3 (
spec.nodeName+Migratingphase). go.mod pins the branch commit via pseudo-version; bump to the cocoon-common release tag after #3 merges.Tests
migrate_test.go(7 transitions incl. both ordering gates),pods_test.go(3 affinity cases); full suite +make lintclean on linux + darwin.Not in scope
Control-plane
migrateAPI + IP backfill + involuntary-eviction reconcile (simular-pro-vm-service); end-to-end + crash-injection tests (need a cluster).