vmware-tanzu / vm-operator

Self-service manage your virtual infrastructure...
Other
106 stars 48 forks source link

🐛 Set bus number when adding SATA controllers for CD-ROM assignment #789

Closed dilyar85 closed 3 weeks ago

dilyar85 commented 3 weeks ago

What does this PR do, and why is it needed?

This PR updates the CD-ROM assignment to use govmomi's CreateSATAController() function when adding a new SATA controller. This ensures that new SATA controllers are created with a proper bus number. Otherwise, adding two or more SATA controllers would fail due to duplicate bus numbers (default with 0) among these controllers.

Which issue(s) is/are addressed by this PR?

Fix N/A.

Are there any special notes for your reviewer:

This change is verified by:

$ kubectl get vm -n sdiliyaer-test 124-cdrom
NAME        POWER-STATE   AGE
124-cdrom   PoweredOn     8m15s

$ govc device.ls -json -vm 124-cdrom cdrom-\* | jq '.devices | length'
124
Complete SATA controllers list with CD-ROMs assigned ```console $ govc device.info -json -vm 124-cdrom ahci-\* | jq '.devices |= sort_by(.key)' { "devices": [ { "name": "ahci-15000", "type": "VirtualAHCIController", "key": 15000, "deviceInfo": { "label": "SATA controller 0", "summary": "AHCI" }, "slotInfo": { "pciSlotNumber": 32 }, "controllerKey": 100, "unitNumber": 24, "busNumber": 0, "device": [ 16017, 16020, 16009, 16000, 16012, 16004, 16021, 16013, 16005, 16006, 16010, 16011, 16027, 16022, 16028, 16001, 16029, 16007, 16008, 16014, 16002, 16023, 16024, 16025, 16026, 16015, 16016, 16003, 16018, 16019 ] }, { "name": "ahci-15001", "type": "VirtualAHCIController", "key": 15001, "deviceInfo": { "label": "SATA controller 1", "summary": "AHCI" }, "slotInfo": { "pciSlotNumber": 33 }, "controllerKey": 100, "unitNumber": 25, "busNumber": 1, "device": [ 16036, 16040, 16032, 16042, 16050, 16051, 16057, 16037, 16038, 16058, 16052, 16033, 16034, 16045, 16046, 16039, 16043, 16047, 16035, 16059, 16030, 16031, 16053, 16054, 16041, 16055, 16048, 16049, 16044, 16056 ] }, { "name": "ahci-15002", "type": "VirtualAHCIController", "key": 15002, "deviceInfo": { "label": "SATA controller 2", "summary": "AHCI" }, "slotInfo": { "pciSlotNumber": 34 }, "controllerKey": 100, "unitNumber": 26, "busNumber": 2, "device": [ 16065, 16071, 16089, 16085, 16086, 16066, 16067, 16077, 16072, 16078, 16087, 16079, 16073, 16060, 16061, 16074, 16075, 16082, 16080, 16083, 16070, 16068, 16069, 16084, 16081, 16063, 16088, 16076, 16062, 16064 ] }, { "name": "ahci-15003", "type": "VirtualAHCIController", "key": 15003, "deviceInfo": { "label": "SATA controller 3", "summary": "AHCI" }, "slotInfo": { "pciSlotNumber": 35 }, "controllerKey": 100, "unitNumber": 27, "busNumber": 3, "device": [ 16109, 16098, 16110, 16105, 16099, 16100, 16106, 16107, 16093, 16108, 16094, 16111, 16112, 16095, 16101, 16117, 16118, 16090, 16096, 16091, 16097, 16092, 16114, 16113, 16115, 16102, 16119, 16103, 16116, 16104 ] } ] } ```

Please add a release note if necessary:

Set bus number when adding SATA controllers for CD-ROM assignment.
github-actions[bot] commented 3 weeks ago

Code Coverage

Package Line Rate Health
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/clustercontentlibraryitem 82%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/contentlibraryitem 85%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/utils 97%
github.com/vmware-tanzu/vm-operator/controllers/infra/capability/configmap 86%
github.com/vmware-tanzu/vm-operator/controllers/infra/capability/crd 93%
github.com/vmware-tanzu/vm-operator/controllers/infra/configmap 71%
github.com/vmware-tanzu/vm-operator/controllers/infra/node 77%
github.com/vmware-tanzu/vm-operator/controllers/infra/secret 77%
github.com/vmware-tanzu/vm-operator/controllers/infra/validatingwebhookconfiguration 85%
github.com/vmware-tanzu/vm-operator/controllers/infra/zone 76%
github.com/vmware-tanzu/vm-operator/controllers/storageclass 95%
github.com/vmware-tanzu/vm-operator/controllers/storagepolicyquota 97%
github.com/vmware-tanzu/vm-operator/controllers/util/encoding 73%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/storagepolicyusage 99%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/virtualmachine 86%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/volume 87%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineclass 75%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinepublishrequest 81%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinereplicaset 68%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice 83%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/providers 92%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinesetresourcepolicy 80%
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/virtualmachinewebconsolerequest/v1alpha2 73%
github.com/vmware-tanzu/vm-operator/pkg/bitmask 100%
github.com/vmware-tanzu/vm-operator/pkg/builder 95%
github.com/vmware-tanzu/vm-operator/pkg/conditions 88%
github.com/vmware-tanzu/vm-operator/pkg/config 100%
github.com/vmware-tanzu/vm-operator/pkg/config/capabilities 100%
github.com/vmware-tanzu/vm-operator/pkg/config/env 100%
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/patch 78%
github.com/vmware-tanzu/vm-operator/pkg/prober 91%
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 75%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/client 80%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/clustermodules 71%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/config 89%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/contentlibrary 74%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/credentials 100%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/network 80%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/placement 79%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/session 71%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/storage 44%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/sysprep 100%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/vcenter 82%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/virtualmachine 84%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/vmlifecycle 67%
github.com/vmware-tanzu/vm-operator/pkg/record 78%
github.com/vmware-tanzu/vm-operator/pkg/topology 91%
github.com/vmware-tanzu/vm-operator/pkg/util 87%
github.com/vmware-tanzu/vm-operator/pkg/util/annotations 100%
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 88%
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/spq 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 97%
github.com/vmware-tanzu/vm-operator/pkg/util/vmopv1 92%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/client 64%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/vm 79%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/watcher 86%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig 95%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/crypto 98%
github.com/vmware-tanzu/vm-operator/pkg/webconsolevalidation 100%
github.com/vmware-tanzu/vm-operator/services/vm-watcher 91%
github.com/vmware-tanzu/vm-operator/webhooks/common 100%
github.com/vmware-tanzu/vm-operator/webhooks/persistentvolumeclaim/validation 95%
github.com/vmware-tanzu/vm-operator/webhooks/unifiedstoragequota/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/mutation 87%
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/virtualmachinepublishrequest/validation 92%
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/virtualmachinewebconsolerequest/v1alpha1/validation 92%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinewebconsolerequest/v1alpha2/validation 92%
Summary 83% (10476 / 12597)

Minimum allowed line rate is 79%