Skip to content

Conversation

@zhangheliu
Copy link
Contributor

@zhangheliu zhangheliu commented Oct 22, 2025

Add comprehensive CD-ROM controller management for the VMSharedDisks
feature including:

  • CD-ROM controller auto-assignment and validation
  • Dynamic IDE/SATA controller creation when needed
  • Webhook mutation for controller spec assignment
  • Webhook validation for controller configuration
  • VM schema upgrade reconciliation for existing VMs
  • Support for CD-ROM placement changes when VM is powered off

This enables proper CD-ROM device management when the VMSharedDisks
capability is enabled, ensuring CD-ROMs are correctly assigned to
available controller slots and new controllers are created as needed.

When VMSharedDisks is enabled, the operator now supports changing CD-ROM
placement (controller type, bus number, or unit number) when the VM is
powered off. Placement changes are handled via a remove-and-add pattern,
removing the CD-ROM with outdated placement and recreating it with the
new controller assignment. Webhook validation prevents such changes when
the VM is powered on.

Which issue(s) is/are addressed by this PR? (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes # N/A

Are there any special notes for your reviewer:
#1241 needs to be merged first.

Please add a release note if necessary:

Introduce CD-ROM support for VMSharedDisks

@github-actions github-actions bot added the size/XXL Denotes a PR that changes 1000+ lines. label Oct 22, 2025
@zhangheliu zhangheliu force-pushed the zhangheliu/feature/shared-disk-cdrom branch from c9c1149 to 209e396 Compare October 22, 2025 17:08
@zhangheliu zhangheliu force-pushed the zhangheliu/feature/shared-disk-cdrom branch from 209e396 to fc2d256 Compare October 24, 2025 11:57
@zhangheliu zhangheliu requested a review from abaruni October 24, 2025 17:27
@zhangheliu zhangheliu force-pushed the zhangheliu/feature/shared-disk-cdrom branch from fc2d256 to 17ddd0b Compare October 24, 2025 21:25
Copy link
Contributor

@lubronzhan lubronzhan left a comment

Choose a reason for hiding this comment

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

Long PR, thanks for the work! My question is mainly around edge cases.

@zhangheliu zhangheliu force-pushed the zhangheliu/feature/shared-disk-cdrom branch 3 times, most recently from 3618af2 to 75bec62 Compare October 28, 2025 09:10
)

const (
// IDEControllerMaxSlotCount is the maximum number of slots
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a review from https://github.com/vmware-tanzu/vm-operator/pull/1244/files#r2469798582. I will update this as well once the mentioned PR is merged to align with the change.


ctrlMap, ctrlUsedUnitNumMap := buildControllerMaps(curDevices)

for bFileName, cdrom := range expectedCdromDevices {
Copy link
Contributor

Choose a reason for hiding this comment

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

The api says

// CD-ROM devices can be added, updated, or removed when the VM is powered
	// off.

Now here we only handle add I think? Should we at least have a TODO for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Previous thread mentioned edit https://github.com/vmware-tanzu/vm-operator/pull/1261/files#r2462256036. I think we are also missing delete

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They all handled it with the existing logic. We are not changing anything about how devices (CD-ROMs) are attached, but instead of adding a new device change for a new controller, we just update the vm.spec.hardware.controller.

And let the virtualmachine controller reconciler add the device change for adding a new controller.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, too dumb that I missed the && at the end and though that's an assignment.
Then just the edit is left over? Since we are not checking whether the current controller has corresponding busNumber/Type/slotNumber

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 for the great catch! Just added support for "edit" the CD-ROM controller placement spec

@lubronzhan
Copy link
Contributor

Have you verified in a real env?

@zhangheliu zhangheliu force-pushed the zhangheliu/feature/shared-disk-cdrom branch from 75bec62 to 838ecf9 Compare October 29, 2025 12:21
@zhangheliu
Copy link
Contributor Author

Have you verified in a real env?

Not yet since changes are behind FSS. I am thinking about doing end-to-end testing once the majority of the PRs are in.

@zhangheliu zhangheliu force-pushed the zhangheliu/feature/shared-disk-cdrom branch 2 times, most recently from e04bf60 to 95b0729 Compare October 29, 2025 16:38
Add comprehensive CD-ROM controller management for the VMSharedDisks
feature including:

- CD-ROM controller auto-assignment and validation
- Dynamic IDE/SATA controller creation when needed
- Webhook mutation for controller spec assignment
- Webhook validation for controller configuration
- VM schema upgrade reconciliation for existing VMs
- Support for CD-ROM placement changes when VM is powered off

This enables proper CD-ROM device management when the VMSharedDisks
capability is enabled, ensuring CD-ROMs are correctly assigned to
available controller slots and new controllers are created as needed.

When VMSharedDisks is enabled, the operator now supports changing CD-ROM
placement (controller type, bus number, or unit number) when the VM is
powered off. Placement changes are handled via a remove-and-add pattern,
removing the CD-ROM with outdated placement and recreating it with the
new controller assignment. Webhook validation prevents such changes when
the VM is powered on.
@zhangheliu zhangheliu force-pushed the zhangheliu/feature/shared-disk-cdrom branch from 95b0729 to 62901cd Compare October 29, 2025 20:03
@github-actions
Copy link

Code Coverage

Package Line Rate Health
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/clustercontentlibraryitem 67%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/contentlibraryitem 67%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/utils 46%
github.com/vmware-tanzu/vm-operator/controllers/infra/capability/configmap 92%
github.com/vmware-tanzu/vm-operator/controllers/infra/capability/crd 100%
github.com/vmware-tanzu/vm-operator/controllers/infra/configmap 75%
github.com/vmware-tanzu/vm-operator/controllers/infra/node 77%
github.com/vmware-tanzu/vm-operator/controllers/infra/secret 76%
github.com/vmware-tanzu/vm-operator/controllers/infra/validatingwebhookconfiguration 87%
github.com/vmware-tanzu/vm-operator/controllers/infra/zone 73%
github.com/vmware-tanzu/vm-operator/controllers/storageclass 95%
github.com/vmware-tanzu/vm-operator/controllers/storagepolicyquota 98%
github.com/vmware-tanzu/vm-operator/controllers/util/encoding 73%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/storagepolicyusage 96%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/virtualmachine 67%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/volume 87%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/volumebatch 81%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineclass 73%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinegroup 89%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinegrouppublishrequest 88%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineimagecache 88%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinepublishrequest 82%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinereplicaset 68%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice 82%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/providers 92%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinesetresourcepolicy 81%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinesnapshot 92%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest 76%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha1 72%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha1/conditions 88%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha1/patch 78%
github.com/vmware-tanzu/vm-operator/controllers/vspherepolicy/policyevaluation 93%
github.com/vmware-tanzu/vm-operator/pkg/bitmask 100%
github.com/vmware-tanzu/vm-operator/pkg/builder 94%
github.com/vmware-tanzu/vm-operator/pkg/conditions 90%
github.com/vmware-tanzu/vm-operator/pkg/config 100%
github.com/vmware-tanzu/vm-operator/pkg/config/capabilities 98%
github.com/vmware-tanzu/vm-operator/pkg/config/env 100%
github.com/vmware-tanzu/vm-operator/pkg/context 25%
github.com/vmware-tanzu/vm-operator/pkg/context/generic 100%
github.com/vmware-tanzu/vm-operator/pkg/context/operation 100%
github.com/vmware-tanzu/vm-operator/pkg/crd 75%
github.com/vmware-tanzu/vm-operator/pkg/errors 75%
github.com/vmware-tanzu/vm-operator/pkg/exit 100%
github.com/vmware-tanzu/vm-operator/pkg/log 100%
github.com/vmware-tanzu/vm-operator/pkg/mem 100%
github.com/vmware-tanzu/vm-operator/pkg/patch 78%
github.com/vmware-tanzu/vm-operator/pkg/prober 89%
github.com/vmware-tanzu/vm-operator/pkg/prober/probe 90%
github.com/vmware-tanzu/vm-operator/pkg/prober/worker 77%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere 74%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/clustermodules 73%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/config 88%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/contentlibrary 75%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/credentials 100%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/network 81%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/placement 74%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/session 51%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/storage 44%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/upgrade/virtualmachine 95%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/vcenter 85%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/virtualmachine 87%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/vmlifecycle 71%
github.com/vmware-tanzu/vm-operator/pkg/record 87%
github.com/vmware-tanzu/vm-operator/pkg/topology 91%
github.com/vmware-tanzu/vm-operator/pkg/util 78%
github.com/vmware-tanzu/vm-operator/pkg/util/cloudinit 89%
github.com/vmware-tanzu/vm-operator/pkg/util/cloudinit/validate 91%
github.com/vmware-tanzu/vm-operator/pkg/util/image 100%
github.com/vmware-tanzu/vm-operator/pkg/util/kube 95%
github.com/vmware-tanzu/vm-operator/pkg/util/kube/cource 100%
github.com/vmware-tanzu/vm-operator/pkg/util/kube/internal 100%
github.com/vmware-tanzu/vm-operator/pkg/util/kube/proxyaddr 73%
github.com/vmware-tanzu/vm-operator/pkg/util/kube/spq 99%
github.com/vmware-tanzu/vm-operator/pkg/util/linuxprep 97%
github.com/vmware-tanzu/vm-operator/pkg/util/netplan 100%
github.com/vmware-tanzu/vm-operator/pkg/util/nil 100%
github.com/vmware-tanzu/vm-operator/pkg/util/ovfcache 75%
github.com/vmware-tanzu/vm-operator/pkg/util/ovfcache/internal 100%
github.com/vmware-tanzu/vm-operator/pkg/util/paused 100%
github.com/vmware-tanzu/vm-operator/pkg/util/ptr 100%
github.com/vmware-tanzu/vm-operator/pkg/util/resize 98%
github.com/vmware-tanzu/vm-operator/pkg/util/sysprep 98%
github.com/vmware-tanzu/vm-operator/pkg/util/vmopv1 88%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/client 66%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/library 96%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/vm 79%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/watcher 85%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig 95%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/anno2extraconfig 100%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/bootoptions 88%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/crypto 91%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/diskpromo 100%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/policy 96%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/virtualcontroller 85%
github.com/vmware-tanzu/vm-operator/pkg/webconsolevalidation 100%
github.com/vmware-tanzu/vm-operator/services/vm-watcher 85%
github.com/vmware-tanzu/vm-operator/webhooks/common 98%
github.com/vmware-tanzu/vm-operator/webhooks/persistentvolumeclaim/validation 95%
github.com/vmware-tanzu/vm-operator/webhooks/unifiedstoragequota/validation 88%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/mutation 85%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/validation 95%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/mutation 62%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinegroup/mutation 87%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinegroup/validation 92%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinegrouppublishrequest/mutation 86%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinegrouppublishrequest/validation 88%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinepublishrequest/validation 93%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinereplicaset/validation 90%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/mutation 67%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/validation 92%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesetresourcepolicy/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesnapshot/mutation 83%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesnapshot/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinewebconsolerequest/v1alpha1/validation 92%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinewebconsolerequest/validation 92%
Summary 82% (16547 / 20134)

Minimum allowed line rate is 79%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XXL Denotes a PR that changes 1000+ lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants