SPLAT-2703: Add durable VMotion execution and recovery state #231
All Vouch review confidence checks passed
Residual risk 0.33 = Change Risk (0.59) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.59 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #231"
general
weight: 0.35
jcpowermac
Dependency and review scope
Depends on #228. Merge the read-only VMotion planning foundation first.
This implements PR 3 — Durable execution and recovery state machine from the UPI cross-vCenter VMotion implementation plan, under SPLAT-2703 / epic SPLAT-2901.
This branch includes PR #228 planning head
4f530a1bbeab0145cf29f77ae8e33baa28134507through a history-preserving merge. Because #228 is still open and this PR targets upstreammain, GitHub includes its prerequisite commits. The initial PR 3 implementation starts with the following two commits; review-fix commits are listed below:1.
2cb78df53— durable execution/recovery implementation and regression tests.2.
208ce0717— implementation rationale, runtime boundaries, and PR 3 checklist.Review only the PR 3 changes.
SPLAT-2703 covers both planning and durable execution. SPLAT-2704's title currently mentions durable execution, but its description and acceptance criteria describe the separate PR 4 vSphere adapter; SPLAT-2703 is the confirmed attribution here.
Summary and motivation
Add the bounded controller component that records and observes external VM actions safely across reconciliation, conflicts, pause, restart/leader takeover, late results, recovery requests, and deletion handoff.
Kubernetes status updates and vCenter operations do not share an atomic transaction. Leader election alone cannot fence a previous external submission. Consequently, a claimed action whose submission outcome is unknown must be observed or escalated, never automatically replayed. This PR implements that conservative boundary using the existing migration CR and shared backend contract rather than adding lock resources, an external workflow service, or an unbounded journal.
This does not enable production VMotion submission. The new submission helper has no production workflow caller. The production recovery verifier is also intentionally unconfigured until later orchestration supplies the required live evidence.
Implementation and rationale
1. Single-winner claims and identity-bound writes
internal/controller/vmotion_execution.goreads the authoritative CR throughAPIReaderand applies resourceVersion-protected status updates with bounded conflict retries.Running, no deletion, no intervention, and the expected prior action when claiming new work.This is a claim-once/observe protocol, not an exactly-once execution guarantee. A crash between acknowledged claim and external request can deliberately require administrator intervention.
2. Observation is separate from mutation permission
Handle an existing VMotion action before normal pause/spec-selection and deletion workflow gates. Matching observations can be persisted after pause or generation changes, including removal of the VMotion selector, while the existing general
executionContextmutation guard stays strict.Results are conditional on the same action/task snapshot. A stale writer cannot replace a newer action, concurrent task binding, or terminal result; unrelated status fields survive conflict retries. This prevents stale observations from becoming replay authority.
3. Independent outcomes and owning-vCenter task scope
ShutdownGuesttaskless and observe the frozen VM's actual power state. A successful request return alone does not establish shutdown completion.Task success is not Node completion: destination placement, preserved identity, fresh Node heartbeat, and applicable etcd recovery remain later workflow gates.
4. Deadlines, bounded reads, and polling
Start shutdown, relocation, and power-on action deadlines at six hours, with
TODO(SPLAT-2703)beside the constant requiring qualification of that initial value.Expiry blocks further actions and retains intervention while observation continues. A late successful result updates its independent outcome without automatically clearing intervention or permitting the next action.
Use separate 30-second read budgets and polling intervals, following the existing long-wait cadence:
RequeueAfteralone does not prevent those events from immediately polling again.5. Evidence-gated, action-bound recovery
internal/controller/vmotion_recovery.gotreats a recovery request as an instruction to revalidate, not a force-clear flag.Claimedaction until its persisted submission deadline expires. External inactivity alone cannot fence an original claimant suspended before sending its request.Runningrequirement for a new mutation.The nil production verifier fails closed. Later orchestration must supply and qualify those evidence checks before recovery is enabled.
6. Deletion retention and explicit handoff
Continue observing an existing action while deletion retains the execution record. Do not run legacy progression, preparation, new VM actions, cancellation, rollback, or VM deletion from that path.
Unresolved VMotion actions prevent completion-based finalizer release. Preserve the existing explicit
migration.openshift.io/allow-deletion: "true"administrator handoff even when the backend is unavailable; handoff is not proof of success or permission to recover a VM or clean up source references.Tests and review fixes
The implementation and review fixes include 35 focused test functions, including table-driven cases, exercising the real controller status logic against Kubernetes fake-client conflict behavior and fake external backends:
| Area | Evidence covered |
| --- | --- |
| Claims and crash windows | Competing reconciles, resourceVersion conflicts, lost claim acknowledgement, crash after claim/before request, failed task persistence, restart without a task reference, and no blind duplicate submission |
| Identity and stale writes | Replaced CR/execution/plan/Node identity, newer actions, terminal results, concurrent unrelated status, and wrong-owner task references |
| Pause and results | Pause before claim and after a winning claim, generation changes, independent relocation/power-on outcomes, and no recovery bypass of pause |
| Deadlines | Graceful-shutdown timeout and late completion, task success after six hours, and intervention retained after late success |
| Recovery | Action-bound requests, one-time consumption, stale evidence, unavailable verifier, expired claims, new retry IDs, and a suspended original claimant that must not be outrun |
| Reconciliation liveness | Bounded observation/verification, deletion handoff after read timeout or without a backend, and self-generated status watch events that must not create an immediate polling loop |
A fresh review identified three important issues: recovery could race an original claimant, reads were initially unbounded, and status writes could bypass the polling interval. Each was reproduced by a failing regression test, fixed, and followed by passing focused and repository verification. Timeout/polling tests use Go virtual time rather than real six-hour waits.
Documentation and compatibility
docs/dev/vmotion-execution.mdwith the protocol, design rationale, dependency boundaries, and qualification limits.targetDatacenterstatus and synchronize the direct-install/bundle CRD schemas. No RBAC, packaging-layout or dependency changes are required.Validation
Run successfully on the committed source tree before publication:
make test— repository unit, envtest, and simulator suitesmake lint— repository-pinned golangci-lint, 0 issuesmake buildgo test -race ./internal/controller -run TestVMotion -count=1git diff --checkThe generated direct-install and bundle CRD schemas include the bounded
targetDatacenterfield for both roles. DeepCopy generation produced no additional changes for this scalar field; RBAC is unchanged.Remaining qualification / delivery boundary
The real vSphere adapter, SDK retry/cancellation/session-cache semantics, fresh workflow admission and recovery evidence, control-plane health integration, availability packaging, and guarded cleanup remain their planned follow-ups. The six-hour deadlines and exact platform combinations still require qualification. No real cross-vCenter lab or cluster E2E qualification was performed; fake-backend, envtest, and simulator success is not release qualification.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
New Features
Migration progress can record a destination datacenter for each node; changes to the recorded destination are detected as plan drift.
Recovery status distinguishes blocked requests from verified recovery. Existing VMotion actions can be observed and recorded across pauses and spec changes, with safeguards against uncertain outcomes.
Bug Fixes
Deletion safeguards retain migration resources while VMotion actions remain unresolved, unless the administrator uses the deletion override.
Documentation
* Updated VMotion documentation to clarify safeguards and remaining limitations, including that production action submission is not enabled.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Review follow-up: review 5705746848
All three findings in the linked review are addressed in focused commits with detailed messages:
Each finding has a regression reproduced before its fix. After all fixes, make test, make lint (0 issues), make build, the focused VMotion/frozen-node race suite and git diff --check pass. Replies in all three inline review threads describe the changes and evidence. Production submission and the qualified recovery verifier remain disconnected; the six-hour qualification TODO remains in place.
Planning dependency synchronization
Merge commit 4bde47205 carries PR #228 planning fixes 5d7e4dd50 and 4f530a1bb into this branch without rewriting published commits. These fix nested-datacenter scope and implement the approved Machine API B/C ownership/provisioning policy: complete parent/remediation evidence, resolved-absent annotations only after all other checks, IP-only/contradictory evidence vetoes, terminating-Node and malformed-reference rejection, and fresh eligibility reads after inventory.
Engine-switch flaw A remains explicitly deferred, CAPI is outside release scope, and snapshots are not external-operation fencing. The execution submission/recovery boundaries and existing frozen target-datacenter field remain intact. See
docs/dev/vmotion-eligibility.mdand PR #228 for the detailed policy and regression evidence.The combined branch passes
make test,make lint(0 issues),make build, focused VMotion/frozen-node/reference-parser controller race tests, inventory simulator race tests, and diff checks. No actual cross-vCenter qualification was performed.