Skip to content

Comments

MTV-2419 | VM spec should be preserved if possible#4290

Open
gwencasey96 wants to merge 2 commits intokubev2v:mainfrom
gwencasey96:vm-spec-should-be-preserved-if-possibler
Open

MTV-2419 | VM spec should be preserved if possible#4290
gwencasey96 wants to merge 2 commits intokubev2v:mainfrom
gwencasey96:vm-spec-should-be-preserved-if-possibler

Conversation

@gwencasey96
Copy link
Contributor

MTV-2419 | VM spec should be preserved if possible

When migrating a VM from OCP to OCP, if the source VM had a dataVolumeTemplate, the target VM will now preserve it. Previously, the target VM only referenced the target PVC, but some user workflows may expect the VM's DataVolume to be present.

This fix:

  1. Updates the OCP builder to copy DataVolumeTemplates from the source VM spec
  2. Updates vmTemplate to preserve DataVolumeTemplates when source is OCP

Resolves: MTV-2419

@codecov-commenter
Copy link

codecov-commenter commented Jan 12, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 69 lines in your changes missing coverage. Please review.
✅ Project coverage is 8.28%. Comparing base (f1fe5d0) to head (d881d33).
⚠️ Report is 1569 commits behind head on main.

Files with missing lines Patch % Lines
pkg/controller/plan/adapter/ocp/builder.go 0.00% 67 Missing ⚠️
pkg/controller/plan/kubevirt.go 0.00% 2 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff            @@
##             main   #4290      +/-   ##
=========================================
- Coverage   15.45%   8.28%   -7.17%     
=========================================
  Files         112     461     +349     
  Lines       23377   52293   +28916     
=========================================
+ Hits         3613    4333     +720     
- Misses      19479   47578   +28099     
- Partials      285     382      +97     
Flag Coverage Δ
unittests 8.28% <0.00%> (-7.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mrnold
Copy link
Contributor

mrnold commented Jan 13, 2026

I am trying to understand what this does. It looks like if you have a VM with a DataVolumeTemplate on one OpenShift cluster, and then migrate it to another cluster, the resulting VM spec will keep a copy of that DataVolumeTemplate. And this DataVolumeTemplate will create a DataVolume that adopts the existing destination PVC that forklift created during the migration?

Do I have it right, or is there more to it than this? It seems simple enough but I am not clear on whether or not there are other side effects. Would the PVC namespace in the DataVolumeTemplate need to be adjusted for the destination migration namespace?

object.Template = targetVmSpec.Template
// Preserve DataVolumeTemplates from source VM to maintain user workflows
// that may expect the VM's DataVolume to be present
object.DataVolumeTemplates = targetVmSpec.DataVolumeTemplates
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This preserves the spec, but what about the disks themselves referenced in the spec?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you-there were a few things in my initial PR I needed to think through more. Now the DataVolumeTemplate names are mapped to the PVC names that Forklift uses when creating DataVolumes and sanitized. The volume references will also be updated when template names change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The disk references are preserved in line above so we don't need anything else

	object.Template = targetVmSpec.Template

but still question is: Are we migrating the datavolume referenced in the VM?
If you look at the export api which is used for the cold migraiton it support datavolumes. Are we using it already in a way that the datavolumes data are copied?

When migrating a VM from OCP to OCP, if the source VM had a dataVolumeTemplate,
the target VM will now preserve it. Previously, the target VM only referenced
the target PVC, but some user workflows may expect the VM's DataVolume to be present.

This fix:
1. Updates the OCP builder to copy DataVolumeTemplates from the source VM spec
2. Updates vmTemplate to preserve DataVolumeTemplates when source is OCP

Resolves: MTV-2419
Signed-off-by: Gwen Casey <gcasey@redhat.com>
…klift-created DataVolumes

When preserving DataVolumeTemplates for OCP-to-OCP migrations, we need to:
1. Match template names to PVC names (Forklift creates DataVolumes with Name = pvc.Name)
2. Clear spec.source to prevent KubeVirt from trying to create new DataVolumes with invalid source URLs
3. Update volume references when DataVolumeTemplate names change

This ensures that preserved DataVolumeTemplates correctly reference the DataVolumes
that Forklift creates during migration, preventing conflicts and ensuring the VM
can start successfully.

Resolves: MTV-2419
Signed-off-by: Gwen Casey <gcasey@redhat.com>
@gwencasey96 gwencasey96 force-pushed the vm-spec-should-be-preserved-if-possibler branch from 33de0d9 to d881d33 Compare January 15, 2026 17:34
@sonarqubecloud
Copy link

Copy link
Member

@mnecas mnecas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not understanding some parts.
Mainly

object.Template = targetVmSpec.Template
// Preserve DataVolumeTemplates from source VM to maintain user workflows
// that may expect the VM's DataVolume to be present
object.DataVolumeTemplates = targetVmSpec.DataVolumeTemplates
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The disk references are preserved in line above so we don't need anything else

	object.Template = targetVmSpec.Template

but still question is: Are we migrating the datavolume referenced in the VM?
If you look at the export api which is used for the cold migraiton it support datavolumes. Are we using it already in a way that the datavolumes data are copied?

// 2. Clear spec.source to prevent KubeVirt from trying to create new DataVolumes with invalid sources
// 3. Ensure namespace is set correctly (will be set by KubeVirt to match VM namespace)
// 4. Update volume references to match renamed DataVolumeTemplates
r.sanitizeDataVolumeTemplates(vmRef, object.DataVolumeTemplates, object)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think we need this we are trying to persist the VM spec as much as possible to the source, my main question was about the disks themselves and the data on them

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.

4 participants