From 2e93700c4720dee85cc2d1803b8f05f5cd34e486 Mon Sep 17 00:00:00 2001 From: Martin Necas Date: Tue, 7 Jan 2025 09:20:34 +0100 Subject: [PATCH] MTV-1866 | Remove the requests.memory from the builder Issue: MTV is importing VMs with the requests.memory field and the memory.guest field set. This is problematic as it prevents memor-overcommit and is causing un-necessary memory pressure on VMs in the worst case leading to OOM sitiations. Fix: Remove the requests.memory from the builders Ref: https://issues.redhat.com/browse/MTV-1866 Signed-off-by: Martin Necas --- pkg/controller/plan/adapter/openstack/builder.go | 4 ---- pkg/controller/plan/adapter/ova/builder.go | 5 ----- pkg/controller/plan/adapter/ovirt/builder.go | 5 ----- pkg/controller/plan/adapter/vsphere/builder.go | 5 ----- 4 files changed, 19 deletions(-) diff --git a/pkg/controller/plan/adapter/openstack/builder.go b/pkg/controller/plan/adapter/openstack/builder.go index fc703c332..f2cdfa5fe 100644 --- a/pkg/controller/plan/adapter/openstack/builder.go +++ b/pkg/controller/plan/adapter/openstack/builder.go @@ -440,11 +440,7 @@ func (r *Builder) mapResources(vm *model.Workload, object *cnv.VirtualMachineSpe // TODO Support HugePages memory := resource.NewQuantity(int64(vm.Flavor.RAM)*1024*1024, resource.BinarySI) - resourceRequests := map[core.ResourceName]resource.Quantity{} - resourceRequests[core.ResourceMemory] = *memory object.Template.Spec.Domain.Memory = &cnv.Memory{Guest: memory} - - object.Template.Spec.Domain.Resources.Requests = resourceRequests } func (r *Builder) getCpuCount(vm *model.Workload, imageCpuProperty string) (count uint32) { diff --git a/pkg/controller/plan/adapter/ova/builder.go b/pkg/controller/plan/adapter/ova/builder.go index db442ffd2..be007eedd 100644 --- a/pkg/controller/plan/adapter/ova/builder.go +++ b/pkg/controller/plan/adapter/ova/builder.go @@ -316,11 +316,6 @@ func (r *Builder) mapMemory(vm *model.VM, object *cnv.VirtualMachineSpec) error return err } reservation := resource.NewQuantity(memoryBytes, resource.BinarySI) - object.Template.Spec.Domain.Resources = cnv.ResourceRequirements{ - Requests: map[core.ResourceName]resource.Quantity{ - core.ResourceMemory: *reservation, - }, - } object.Template.Spec.Domain.Memory = &cnv.Memory{Guest: reservation} return nil } diff --git a/pkg/controller/plan/adapter/ovirt/builder.go b/pkg/controller/plan/adapter/ovirt/builder.go index 60390998d..01401d79e 100644 --- a/pkg/controller/plan/adapter/ovirt/builder.go +++ b/pkg/controller/plan/adapter/ovirt/builder.go @@ -362,11 +362,6 @@ func (r *Builder) mapClock(vm *model.Workload, object *cnv.VirtualMachineSpec) { func (r *Builder) mapMemory(vm *model.Workload, object *cnv.VirtualMachineSpec) { reservation := resource.NewQuantity(vm.Memory, resource.BinarySI) - object.Template.Spec.Domain.Resources = cnv.ResourceRequirements{ - Requests: map[core.ResourceName]resource.Quantity{ - core.ResourceMemory: *reservation, - }, - } object.Template.Spec.Domain.Memory = &cnv.Memory{Guest: reservation} } diff --git a/pkg/controller/plan/adapter/vsphere/builder.go b/pkg/controller/plan/adapter/vsphere/builder.go index c68e7f18a..cf1939631 100644 --- a/pkg/controller/plan/adapter/vsphere/builder.go +++ b/pkg/controller/plan/adapter/vsphere/builder.go @@ -647,11 +647,6 @@ func (r *Builder) setMachine(object *cnv.VirtualMachineSpec) { func (r *Builder) mapMemory(vm *model.VM, object *cnv.VirtualMachineSpec) { memoryBytes := int64(vm.MemoryMB) * 1024 * 1024 reservation := resource.NewQuantity(memoryBytes, resource.BinarySI) - object.Template.Spec.Domain.Resources = cnv.ResourceRequirements{ - Requests: map[core.ResourceName]resource.Quantity{ - core.ResourceMemory: *reservation, - }, - } object.Template.Spec.Domain.Memory = &cnv.Memory{Guest: reservation} }