Fix offline migration with a hotplugged volume#48
Open
awels wants to merge 1 commit intokubevirt:mainfrom
Open
Fix offline migration with a hotplugged volume#48awels wants to merge 1 commit intokubevirt:mainfrom
awels wants to merge 1 commit intokubevirt:mainfrom
Conversation
When migrating an offline VM with hotplugged volumes, the controller was attempting to update DataVolumeTemplate entries for all volumes being migrated. However, hotplugged volumes don't have corresponding DataVolumeTemplate entries (they're in spec.template.spec.volumes with hotpluggable:true, but not in spec.dataVolumeTemplates). This caused KubeVirt's admission webhook to reject the VM update with: "DataVolumeTemplate entry spec.dataVolumeTemplate[0] must be referenced in the VMI template's 'volumes' list" Changes: - Track which volumes are present in spec.template.spec.volumes - Only update DataVolumeTemplates if corresponding volume is in template - Skip DVTemplate updates for hotplugged volumes (no DVTemplate exists) - Add comprehensive test with 4 naming combinations: 1. Both volumes have explicit target names 2. Regular explicit, hotplug generated suffix 3. Regular generated suffix, hotplug explicit 4. Both use generated suffix names Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Alexander Wels <awels@redhat.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
akalenyu
reviewed
Apr 12, 2026
| vmCopy := vm.DeepCopy() | ||
|
|
||
| // Track which volumes are present in the template and being migrated | ||
| volumesInTemplate := make(map[string]bool) |
Contributor
There was a problem hiding this comment.
just me or we don't usually use the "template" term when reasoning about vmis? so variable names/comments here are bit confusing
| planPVCNameMap[pvc.Name] = pvc.VolumeName | ||
| } | ||
| // Only update DataVolumeTemplates if the corresponding volume is in the template. | ||
| // Hotplugged volumes may have DVTemplates but not be in spec.template.spec.volumes, |
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.
What this PR does / why we need it:
When migrating an offline VM with hotplugged volumes, the controller was attempting to update
DataVolumeTemplate entries for all volumes being migrated. However, hotplugged volumes don't have corresponding DataVolumeTemplate entries (they're in spec.template.spec.volumes with hotpluggable:true, but not in spec.dataVolumeTemplates).
This caused KubeVirt's admission webhook to reject the VM update with: "DataVolumeTemplate
entry spec.dataVolumeTemplate[0] must be referenced in the VMI template's 'volumes' list"
Changes:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
Checklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.
Release note: