Jiří Moskovčák has uploaded a new change for review. Change subject: engine: handle memory allignment when checking the balloon health ......................................................................
engine: handle memory allignment when checking the balloon health Engine used to check if the ballooning works properly by comparing the target memory with the actual available memory and throws a warning if it doesn't match, the problem is when the requsted target memory value is not alligned. The system then returns the alligned memory and the engine thinks the balloon is not working, becuase the requested value != curent value. This patch changes the behaviour so it only checks if the current value is closer to the requested value than the previous value (in other words: if the current memory moves towards the requested target) Change-Id: Ibc308a2049c117e2409f480adfcd4a3da495a0b9 Bug-Url: https://bugzilla.redhat.com/1120197 Signed-off-by: Jiri Moskovcak <jmosk...@redhat.com> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBalloonInfo.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java M backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfoTest.java 3 files changed, 51 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/85/35585/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBalloonInfo.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBalloonInfo.java index 6c84ac9..da521e1 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBalloonInfo.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBalloonInfo.java @@ -11,6 +11,23 @@ private Long balloonTargetMemory; private Long balloonMinMemory; private boolean balloonDeviceEnabled; + /* the previous value of currentMemory, we need this to check if the balloon + * works properly see: VdsUpdateRuntimeInfo.proceedBalloonCheck() + * rhbz#1120197 + */ + transient private Long balloonLastMemory; + + public static long getSerialVersionUID() { + return serialVersionUID; + } + + public Long getBalloonLastMemory() { + return balloonLastMemory; + } + + public void setBalloonLastMemory(Long balloonLastMemory) { + this.balloonLastMemory = balloonLastMemory; + } public Long getCurrentMemory() { return currentMemory; diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java index 7a308b4..03dddb5 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java @@ -1477,6 +1477,11 @@ } } + protected boolean isBalloonWorking(VmBalloonInfo balloonInfo) { + return (Math.abs(balloonInfo.getBalloonLastMemory() - balloonInfo.getBalloonTargetMemory()) + > Math.abs(balloonInfo.getCurrentMemory() - balloonInfo.getBalloonTargetMemory())); + } + private void proceedBalloonCheck() { if (isBalloonActiveOnHost()) { for (VmInternalData vmInternalData : _runningVms.values()) { @@ -1486,14 +1491,22 @@ continue; // if vm is unknown - continue } + if (balloonInfo.getBalloonLastMemory() == 0) { // first time we check, so we don't have enough data yet + balloonInfo.setBalloonLastMemory(balloonInfo.getCurrentMemory()); + continue; + } + if (isBalloonDeviceActiveOnVm(vmInternalData) && (Objects.equals(balloonInfo.getCurrentMemory(), balloonInfo.getBalloonMaxMemory()) - || !Objects.equals(balloonInfo.getCurrentMemory(), balloonInfo.getBalloonTargetMemory()))) { + || !isBalloonWorking(balloonInfo))) { vmBalloonDriverIsRequestedAndUnavailable(vmId); } else { vmBalloonDriverIsNotRequestedOrAvailable(vmId); } + // save the current value for the next time we check it + balloonInfo.setBalloonLastMemory(balloonInfo.getCurrentMemory()); + if (vmInternalData.getVmStatistics().getusage_mem_percent() != null && vmInternalData.getVmStatistics().getusage_mem_percent() == 0 // guest agent is down && balloonInfo.isBalloonDeviceEnabled() // check if the device is present diff --git a/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfoTest.java b/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfoTest.java index 3ed4d4d..c94c186 100644 --- a/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfoTest.java +++ b/backend/manager/modules/vdsbroker/src/test/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfoTest.java @@ -30,6 +30,7 @@ import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VMStatus; +import org.ovirt.engine.core.common.businessentities.VmBalloonInfo; import org.ovirt.engine.core.common.businessentities.VmDevice; import org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType; import org.ovirt.engine.core.common.businessentities.VmDynamic; @@ -345,4 +346,23 @@ vms.put(VM_1, new VmInternalData(vm_1_vdsm.getDynamicData(), null, null, null)); return vms; } + + @Test + public void balloonCheck() { + VmBalloonInfo balloonInfo = new VmBalloonInfo(); + balloonInfo.setBalloonDeviceEnabled(true); + balloonInfo.setBalloonMaxMemory(10000L); + balloonInfo.setBalloonMinMemory(1000L); + + balloonInfo.setBalloonLastMemory(1000L); + balloonInfo.setBalloonTargetMemory(1999L); + balloonInfo.setCurrentMemory(2000L); + assertTrue(updater.isBalloonWorking(balloonInfo)); + + balloonInfo.setBalloonLastMemory(1000L); + balloonInfo.setBalloonTargetMemory(1999L); + balloonInfo.setCurrentMemory(1000L); + assertFalse(updater.isBalloonWorking(balloonInfo)); + + } } -- To view, visit http://gerrit.ovirt.org/35585 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibc308a2049c117e2409f480adfcd4a3da495a0b9 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Jiří Moskovčák <jmosk...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches