Repository navigation
fix: honor matchLabels selector on restore target PVC instead of failing - #199
Conversation
handleAccepted rejected any target PVC declaring spec.selector outright, and validateExistingPVCForBind failed the rebind if the rebound PV's labels didn't already satisfy it. That makes it impossible for a restore plugin to use the same technique Velero's own built-in CSI DataDownload restore path uses (velero.io/dynamic-pv-restore): setting a matchLabels selector on the target PVC to make provisioners skip it entirely, independent of the target StorageClass's volumeBindingMode. Since the rebind PV is one this controller fully owns, reconcile its labels to satisfy a matchLabels-only selector instead of requiring it to already match. matchExpressions is still rejected -- there's no general way to synthesize a label set satisfying an arbitrary expression. This is the controller-side half of removing the WaitForFirstConsumer StorageClass requirement entirely; a companion kubevirt-datamover-plugin change is needed to actually set the selector on restore. Signed-off-by: Tiger Kaovilai <passawit.kaovilai@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change updates PVC rebinding to reconcile ChangesPVC selector reconciliation
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The controller now supports matchLabels-based restore targets and reconciles labels on owned rebound PVs; no actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
race.. fixed in openshift/oadp-operator#2404 (comment) |
|
/test virt-kdm-e2e-test-aws |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kaovilai, shubham-pampattiwar, sseago The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Live end-to-end validation done (cross-session, with the companion plugin fix in migtools/kubevirt-datamover-plugin#50). Ran on a real GCP OCP cluster using a combined image built from this branch + #197 ( Confirmed all three links of the chain, not just "no error":
Unrelated findings from that same run (VM didn't fully reach Ready) are out of scope here: a KubeVirt admission-webhook rejection of reserved Note Responses generated with Claude |
|
Closing the loop on your third pointer (whether Confirmed two ways:
Your other two pointers (plugin setting selector+empty Note Responses generated with Claude |
|
/cherry-pick oadp-1.6 |
|
@kaovilai: new pull request created: #204 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Summary
Supersedes #195 (closed). Per discussion with @sseago: instead of requiring restore-target StorageClasses to use
volumeBindingMode: WaitForFirstConsumer, this teaches the controller to honor the same selector-based technique Velero's own built-in CSI DataDownload restore path already uses (velero.io/dynamic-pv-restore, see vendoredpkg/restore/actions/csi/pvc_action.go'srestoreFromDataUploadResult): setting amatchLabels-onlySpec.Selectoron the target PVC makes dynamic provisioners skip it entirely, regardless ofvolumeBindingMode.What changed
handleAccepted's early-phase gate no longer rejects any target PVC withSpec.Selectorset -- onlymatchExpressions(which we have no general way to satisfy) still fails fast.validateExistingPVCForBindnow reconciles the rebound PV's labels to satisfy amatchLabelsselector instead of requiring them to already match. The PV is one this controller fully owns, so it can just patch the labels the plugin's selector names, rather than needing the plugin and controller to coordinate a label value in advance.matchExpressionsstill rejected,matchLabelsnow succeeds end-to-end (Accepted -> Prepared, and the PV label reconciliation itself).Scope
This is the controller-side half. The companion kubevirt-datamover-plugin change landed in migtools/kubevirt-datamover-plugin#50 (draft), using Velero's own exported
velerov1.DynamicPVRestoreLabelconstant with an operationID-derived, per-(restore,PVC)-unique value.Live end-to-end validation
Validated on a real GCP OCP cluster (combined image
quay.io/tkaovila/kubevirt-datamover-controller:combined-197-199-test+ plugin PR#50's image), cross-session with a peer session driving the plugin side. Confirmed all three links of the chain, not just "no error":Pendingwithspec.selector.matchLabels = {"velero.io/dynamic-pv-restore": "<operationID-derived value>"}.Completed, the bound PV carried that samevelero.io/dynamic-pv-restorelabel (alongsidevelero.io/datadownload-uid).Pending->Bound; the Restore CR showedrestoreItemOperationsAttempted=2, Completed=2.Unrelated findings from that same run (VM didn't fully reach Ready) are out of scope for this PR: a KubeVirt admission-webhook rejection of reserved
kubevirt.io/labels on direct VMI restore (known non-fatal Velero+KubeVirt behavior), and alibvirt SyncVMI/CBT permission-denied error unrelated to PVC rebinding.Test plan
go build ./...go vet ./...go test ./...make lintNote
Responses generated with Claude