Dudi Maroshi has uploaded a new change for review. Change subject: engine: forbid single (vm mem) > (host mem) ......................................................................
engine: forbid single (vm mem) > (host mem) Forbid running single vm with mem > host physical memory. Yet we allow running few vms with total mem > host physical memory. (relying on balloning). This might be unwise yet can occour after migration or/and host downsizing. Whenever the: (vm mem) > (host mem) the host will start swaping and performance degrage. If it possible to think of scenrios vm allocated large mem and not using it, and cannot downsize vm mem. Change-Id: Ia5f5280c43820732a36a235024ec5c887c9fcb98 Bug-Url: https://bugzilla.redhat.com/1180071 modified: backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SlaValidator.java Signed-off-by: Dudi Maroshi <d...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SlaValidator.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/MemoryPolicyUnit.java M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties M frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java M frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 6 files changed, 26 insertions(+), 6 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/29/37429/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SlaValidator.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SlaValidator.java index cec8330..3c6b7b5 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SlaValidator.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SlaValidator.java @@ -22,7 +22,9 @@ double vdsCurrentMem = curVds.getMemCommited() + curVds.getPendingVmemSize() + curVds.getGuestOverhead() + curVds .getReservedMem() + vm.getMinAllocatedMem(); - double vdsMemLimit = curVds.getMaxVdsMemoryOverCommit() * curVds.getPhysicalMemMb() / 100.0; + // if single vm on host. Disregard memory over commitment + int computedMemoryOverCommit = (curVds.getVmCount() == 0) ? 100 : curVds.getMaxVdsMemoryOverCommit(); + double vdsMemLimit = computedMemoryOverCommit * curVds.getPhysicalMemMb() / 100.0; log.debug("hasMemoryToRunVM: host '{}' pending vmem size is : {} MB", curVds.getName(), curVds.getPendingVmemSize()); @@ -37,6 +39,19 @@ return retVal; } + public int getHostAvailableMemoryLimit(VDS curVds) { + if (curVds.getMemCommited() != null && curVds.getPhysicalMemMb() != null && curVds.getReservedMem() != null) { + double vdsCurrentMem = + curVds.getMemCommited() + curVds.getPendingVmemSize() + curVds.getGuestOverhead() + + curVds.getReservedMem(); + // if single vm on host. Disregard memory over commitment + int computedMemoryOverCommit = (curVds.getVmCount() == 0) ? 100 : curVds.getMaxVdsMemoryOverCommit(); + double vdsMemLimit = computedMemoryOverCommit * curVds.getPhysicalMemMb() / 100.0; + return (int) (vdsMemLimit - vdsCurrentMem); + } + return 0; + } + public static Integer getEffectiveCpuCores(VDS vds) { VDSGroup vdsGroup = DbFacade.getInstance().getVdsGroupDao().get(vds.getVdsGroupId()); return getEffectiveCpuCores(vds, vdsGroup != null ? vdsGroup.getCountThreadsAsCores() : false); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/MemoryPolicyUnit.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/MemoryPolicyUnit.java index 844ef18..8e9fecc 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/MemoryPolicyUnit.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/MemoryPolicyUnit.java @@ -6,6 +6,7 @@ import java.util.Map; import org.ovirt.engine.core.bll.scheduling.PolicyUnitImpl; +import org.ovirt.engine.core.bll.scheduling.SlaValidator; import org.ovirt.engine.core.common.businessentities.NumaTuneMode; import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VM; @@ -45,7 +46,11 @@ continue; } if (!memoryChecker.evaluate(vds, vm)) { - log.debug("Host '{}' has insufficient memory to run the VM", vds.getName()); + int hostAavailableMem = SlaValidator.getInstance().getHostAvailableMemoryLimit(vds); + log.debug("Host '{}' has {} MB available. Insufficient memory to run the VM", + vds.getName(), + hostAavailableMem); + messages.addMessage(vds.getId(), String.format("$availableMem %1$d", hostAavailableMem)); messages.addMessage(vds.getId(), VdcBllMessages.VAR__DETAIL__NOT_ENOUGH_MEMORY.toString()); continue; } diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties index d637e27..b3e2b7b 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -1259,7 +1259,7 @@ VAR__DETAIL__LOW_CPU_LEVEL=$detailMessage its CPU level ${hostCPULevel} is lower than the VM requires ${vmCPULevel} VAR__DETAIL__UNSUPPORTED_EMULATED_MACHINE=$detailMessage it doesn't support the emulated machine '${vmEmulatedMachine}' which is required by the VM. Host supported emulated machines are: ${hostEmulatedMachines}. VAR__DETAIL__SWAP_VALUE_ILLEGAL=$detailMessage its swap value was illegal -VAR__DETAIL__NOT_ENOUGH_MEMORY=$detailMessage it has insufficient free memory to run the VM +VAR__DETAIL__NOT_ENOUGH_MEMORY=$detailMessage has availabe ${availableMem} MB memory. Insufficient free memory to run the VM VAR__DETAIL__NOT_MEMORY_PINNED_NUMA=$detailMessage cannot accommodate memory of VM's pinned virtual NUMA nodes within host's physical NUMA nodes. VAR__DETAIL__NOT_ENOUGH_CORES=$detailMessage it does not have enough cores to run the VM VAR__DETAIL__NUMA_PINNING_FAILED=$detailMessage it has insufficient NUMA node free memory to run the VM diff --git a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java index bda3d57..da17114 100644 --- a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java +++ b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java @@ -3347,7 +3347,7 @@ @DefaultStringValue("$detailMessage its swap value was illegal") String VAR__DETAIL__SWAP_VALUE_ILLEGAL(); - @DefaultStringValue("$detailMessage it has insufficient free memory to run the VM") + @DefaultStringValue("$detailMessage has availabe ${availableMem} MB memory. Insufficient free memory to run the VM") String VAR__DETAIL__NOT_ENOUGH_MEMORY(); @DefaultStringValue("$detailMessage cannot accommodate memory of VM's pinned virtual NUMA nodes within host's physical NUMA nodes.") diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index 628e1be..36c1f34 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -1029,7 +1029,7 @@ VAR__DETAIL__LOW_CPU_LEVEL=$detailMessage its CPU level ${hostCPULevel} is lower than the VM requires ${vmCPULevel} VAR__DETAIL__UNSUPPORTED_EMULATED_MACHINE=$detailMessage it doesn't support the emulated machine '${vmEmulatedMachine}' which is required by the VM. Host supported emulated machines are: ${hostEmulatedMachines}. VAR__DETAIL__SWAP_VALUE_ILLEGAL=$detailMessage its swap value was illegal -VAR__DETAIL__NOT_ENOUGH_MEMORY=$detailMessage it has insufficient free memory to run the VM +VAR__DETAIL__NOT_ENOUGH_MEMORY=$detailMessage has availabe ${availableMem} MB memory. Insufficient free memory to run the VM VAR__DETAIL__NOT_MEMORY_PINNED_NUMA=$detailMessage cannot accommodate memory of VM's pinned virtual NUMA nodes within host's physical NUMA nodes. VAR__DETAIL__NOT_ENOUGH_CORES=$detailMessage it does not have enough cores to run the VM VAR__DETAIL__NUMA_PINNING_FAILED=$detailMessage it has insufficient NUMA node free memory to run the VM diff --git a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index 2385e93..250105e 100644 --- a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -1218,7 +1218,7 @@ VAR__DETAIL__LOW_CPU_LEVEL=$detailMessage its CPU level ${hostCPULevel} is lower than the VM requires ${vmCPULevel} VAR__DETAIL__UNSUPPORTED_EMULATED_MACHINE=$detailMessage it doesn't support the emulated machine '${vmEmulatedMachine}' which is required by the VM. Host supported emulated machines are: ${hostEmulatedMachines}. VAR__DETAIL__SWAP_VALUE_ILLEGAL=$detailMessage its swap value was illegal -VAR__DETAIL__NOT_ENOUGH_MEMORY=$detailMessage it has insufficient free memory to run the VM +VAR__DETAIL__NOT_ENOUGH_MEMORY=$detailMessage has availabe ${availableMem} MB memory. Insufficient free memory to run the VM VAR__DETAIL__NOT_MEMORY_PINNED_NUMA=$detailMessage cannot accommodate memory of VM's pinned virtual NUMA nodes within host's physical NUMA nodes. VAR__DETAIL__NOT_ENOUGH_CORES=$detailMessage it does not have enough cores to run the VM VAR__DETAIL__NUMA_PINNING_FAILED=$detailMessage it has insufficient NUMA node free memory to run the VM -- To view, visit http://gerrit.ovirt.org/37429 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia5f5280c43820732a36a235024ec5c887c9fcb98 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Dudi Maroshi <d...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches