From d0e7e4a87b8933a22bbae5e83a2fe27b36f3cea9 Mon Sep 17 00:00:00 2001 From: Em Sharnoff Date: Sat, 12 Oct 2024 12:29:23 -0700 Subject: [PATCH] neonvm-controller: Use virtio-mem when status.memoryProvider is nil Part of #1060. Before we stop setting status.memoryProvider, we need to make sure that an empty status.memoryProvider is interpreted as virtio-mem. We *could* do that everywhere status.memoryProvider is used, but it's probably just easier to do it at top, replacing our handling that originally set DIMM slots by default. --- pkg/neonvm/controllers/vm_controller.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/neonvm/controllers/vm_controller.go b/pkg/neonvm/controllers/vm_controller.go index ce36df021..60bcd075c 100644 --- a/pkg/neonvm/controllers/vm_controller.go +++ b/pkg/neonvm/controllers/vm_controller.go @@ -328,11 +328,15 @@ func (r *VMReconciler) doReconcile(ctx context.Context, vm *vmv1.VirtualMachine) vm.Status.SSHSecretName = fmt.Sprintf("ssh-neonvm-%s", vm.Name) } - // Set memory provider for old VMs that don't have it in the Status. + // Forwards compatibility: Set virtio-mem memory provider for VMs that don't have it in the + // status. + // We need to do this so that when we switch to no longer setting memoryProvider, we won't + // regress and try to set it to dimm slots. + // See #1060 for the relevant tracking issue. if vm.Status.PodName != "" && vm.Status.MemoryProvider == nil { - oldMemProvider := vmv1.MemoryProviderDIMMSlots - log.Error(nil, "Setting default MemoryProvider for VM", "MemoryProvider", oldMemProvider) - vm.Status.MemoryProvider = lo.ToPtr(oldMemProvider) + newMemProvider := vmv1.MemoryProviderVirtioMem + log.Error(nil, "Setting default MemoryProvider for VM", "MemoryProvider", newMemProvider) + vm.Status.MemoryProvider = lo.ToPtr(newMemProvider) } switch vm.Status.Phase {