Skip to content

Commit c6d26ea

Browse files
authored
Merge pull request vmware-tanzu#1450 from bryanv/bryanv/vm-create-match-vmic-by-profile-id
🐛 Match VMIC location by storage profile ID
2 parents 97e04ae + 8b9f34b commit c6d26ea

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

pkg/providers/vsphere/vmprovider_vm.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1884,7 +1884,10 @@ func (vs *vSphereVMProvider) vmCreateGetSourceFilePaths(
18841884
// Check if the files are cached.
18851885
for i := range obj.Status.Locations {
18861886
l := obj.Status.Locations[i]
1887-
if l.DatacenterID == datacenterID && l.DatastoreID == datastoreID {
1887+
if l.DatacenterID == datacenterID &&
1888+
l.DatastoreID == datastoreID &&
1889+
l.ProfileID == createArgs.StorageProfileID {
1890+
18881891
if c := pkgcnd.Get(l, vmopv1.ReadyConditionType); c != nil {
18891892
switch c.Status {
18901893
case metav1.ConditionTrue:

pkg/providers/vsphere/vmprovider_vm_test.go

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,21 +1906,36 @@ func vmTests() {
19061906
conditions.MarkTrue(
19071907
&vmic,
19081908
vmopv1.VirtualMachineImageCacheConditionFilesReady)
1909+
cachedFiles := []vmopv1.VirtualMachineImageCacheFileStatus{
1910+
{
1911+
ID: ctx.ContentLibraryItemDiskPath,
1912+
Type: vmopv1.VirtualMachineImageCacheFileTypeDisk,
1913+
DiskType: vmopv1.VolumeTypeClassic,
1914+
},
1915+
{
1916+
ID: ctx.ContentLibraryItemNVRAMPath,
1917+
Type: vmopv1.VirtualMachineImageCacheFileTypeOther,
1918+
},
1919+
}
1920+
19091921
vmic.Status.Locations = []vmopv1.VirtualMachineImageCacheLocationStatus{
19101922
{
19111923
DatacenterID: ctx.Datacenter.Reference().Value,
19121924
DatastoreID: ctx.Datastore.Reference().Value,
1913-
Files: []vmopv1.VirtualMachineImageCacheFileStatus{
1914-
{
1915-
ID: ctx.ContentLibraryItemDiskPath,
1916-
Type: vmopv1.VirtualMachineImageCacheFileTypeDisk,
1917-
DiskType: vmopv1.VolumeTypeClassic,
1918-
},
1925+
ProfileID: ctx.StorageProfileID,
1926+
Files: cachedFiles,
1927+
Conditions: []metav1.Condition{
19191928
{
1920-
ID: ctx.ContentLibraryItemNVRAMPath,
1921-
Type: vmopv1.VirtualMachineImageCacheFileTypeOther,
1929+
Type: vmopv1.ReadyConditionType,
1930+
Status: metav1.ConditionTrue,
19221931
},
19231932
},
1933+
},
1934+
{
1935+
DatacenterID: ctx.Datacenter.Reference().Value,
1936+
DatastoreID: ctx.Datastore.Reference().Value,
1937+
ProfileID: ctx.EncryptedStorageProfileID,
1938+
Files: cachedFiles,
19241939
Conditions: []metav1.Condition{
19251940
{
19261941
Type: vmopv1.ReadyConditionType,
@@ -4538,6 +4553,7 @@ func vmTests() {
45384553
{
45394554
DatacenterID: ctx.Datacenter.Reference().Value,
45404555
DatastoreID: ctx.Datastore.Reference().Value,
4556+
ProfileID: ctx.StorageProfileID,
45414557
Files: []vmopv1.VirtualMachineImageCacheFileStatus{},
45424558
Conditions: []metav1.Condition{
45434559
{

pkg/providers/vsphere/vmprovider_vm_unmanaged_volumes_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ func unmanagedVolumesTests() {
337337
{
338338
DatacenterID: ctx.Datacenter.Reference().Value,
339339
DatastoreID: ctx.Datastore.Reference().Value,
340+
ProfileID: ctx.StorageProfileID,
340341
Files: []vmopv1.VirtualMachineImageCacheFileStatus{
341342
{
342343
ID: ctx.ContentLibraryItemDiskPath,

0 commit comments

Comments
 (0)