Skip to content

Commit

Permalink
neonvm-controller: Use virtio-mem when status.memoryProvider is nil
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sharnoff committed Oct 12, 2024
1 parent 1a7acbc commit d0e7e4a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/neonvm/controllers/vm_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d0e7e4a

Please sign in to comment.