Skip to content

Commit 7531ccd

Browse files
committed
refactor: sdrs disk placement for multi-disk vms
Ref: #2448 Signed-off-by: Ryan Johnson <[email protected]>
1 parent 2149608 commit 7531ccd

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

vsphere/internal/helper/storagepod/storage_pod_helper.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -480,28 +480,33 @@ func virtualDiskFromDeviceConfigSpecForPlacement(spec types.BaseVirtualDeviceCon
480480
}
481481

482482
func expandVMPodConfigForPlacement(dc []types.BaseVirtualDeviceConfigSpec, pod *object.StoragePod) []types.VmPodConfigForPlacement {
483-
var initialVMConfig []types.VmPodConfigForPlacement
483+
var diskLocators []types.PodDiskLocator
484484

485485
for _, deviceConfigSpec := range dc {
486486
d, ok := virtualDiskFromDeviceConfigSpecForPlacement(deviceConfigSpec)
487487
if !ok {
488488
continue
489489
}
490490

491+
diskLocator := types.PodDiskLocator{
492+
DiskId: d.Key,
493+
DiskBackingInfo: d.Backing,
494+
}
495+
496+
diskLocators = append(diskLocators, diskLocator)
497+
}
498+
499+
// Only create a config if we have disks to place
500+
if len(diskLocators) > 0 {
491501
podConfigForPlacement := types.VmPodConfigForPlacement{
492502
StoragePod: pod.Reference(),
493-
Disk: []types.PodDiskLocator{
494-
{
495-
DiskId: d.Key,
496-
DiskBackingInfo: d.Backing,
497-
},
498-
},
503+
Disk: diskLocators,
499504
}
500505

501-
initialVMConfig = append(initialVMConfig, podConfigForPlacement)
506+
return []types.VmPodConfigForPlacement{podConfigForPlacement}
502507
}
503508

504-
return initialVMConfig
509+
return nil
505510
}
506511

507512
// IsMember checks to see if a datastore is a member of the datastore cluster

0 commit comments

Comments
 (0)