From 82e7be45c1bffba8be9d8eebe3cd3d7877351ea5 Mon Sep 17 00:00:00 2001 From: Sreyas Natarajan Date: Wed, 3 Jul 2024 14:34:13 -0700 Subject: [PATCH] Ignore VM Class specified default guestID "otherGuest64" The VM Class specified guestID is not supported. Ignore if set. The guestID is either specified explicity by - the VM spec (or) - falls back to the VM Image/OVF --- pkg/providers/vsphere/virtualmachine/configspec.go | 3 +-- pkg/util/configspec.go | 1 + pkg/util/configspec_test.go | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/providers/vsphere/virtualmachine/configspec.go b/pkg/providers/vsphere/virtualmachine/configspec.go index 684c68c66..64ddaf3dc 100644 --- a/pkg/providers/vsphere/virtualmachine/configspec.go +++ b/pkg/providers/vsphere/virtualmachine/configspec.go @@ -115,9 +115,8 @@ func CreateConfigSpec( } } - // Initially set the guest ID in ConfigSpec to ensure VM is created with the expected guest ID. + // If VM Spec guestID is specified, initially set the guest ID in ConfigSpec to ensure VM is created with the expected guest ID. // Afterwards, only update it if the VM spec guest ID differs from the VM's existing ConfigInfo. - // If the class also specifies a guest ID, it will be overridden by the VM spec guest ID. if guestID := vmCtx.VM.Spec.GuestID; guestID != "" { configSpec.GuestId = guestID } diff --git a/pkg/util/configspec.go b/pkg/util/configspec.go index e98d5cdf8..9e8a01ccb 100644 --- a/pkg/util/configspec.go +++ b/pkg/util/configspec.go @@ -139,6 +139,7 @@ func SanitizeVMClassConfigSpec( // These are unique for each VM. configSpec.Uuid = "" configSpec.InstanceUuid = "" + configSpec.GuestId = "" // Empty Files as they usually ref files in disk configSpec.Files = nil diff --git a/pkg/util/configspec_test.go b/pkg/util/configspec_test.go index e14f2514b..54f4dbf85 100644 --- a/pkg/util/configspec_test.go +++ b/pkg/util/configspec_test.go @@ -262,6 +262,7 @@ var _ = Describe("SanitizeVMClassConfigSpec", func() { Name: "dummy-VM", Annotation: "test-annotation", Uuid: "uuid", + GuestId: "dummy-guestID", InstanceUuid: "instanceUUID", Files: &vimtypes.VirtualMachineFileInfo{}, VmProfile: []vimtypes.BaseVirtualMachineProfileSpec{ @@ -344,6 +345,7 @@ var _ = Describe("SanitizeVMClassConfigSpec", func() { Expect(configSpec.Annotation).To(Equal("test-annotation")) Expect(configSpec.Uuid).To(BeEmpty()) Expect(configSpec.InstanceUuid).To(BeEmpty()) + Expect(configSpec.GuestId).To(BeEmpty()) Expect(configSpec.Files).To(BeNil()) Expect(configSpec.VmProfile).To(BeEmpty())