Arik Hadas has uploaded a new change for review. Change subject: core: do not decrease pending resources twice on run vm ......................................................................
core: do not decrease pending resources twice on run vm We used to decrease the pending resources twice when running VM - when the VM is switched to powering-up (onPoweringUp) and when it is switched to up (runningSucceeded). The problem is that we don't update the cached field, lastDecreasedVds, so on runningSucceeded we don't know that the pending resources were already been decreased. This patch changes the pending decrement in onPoweringUp method such that the VDS we are decrementing the pending resources from will be cached. Change-Id: Ie73f98504ae61ec20a722501fdd49930892dd80a Signed-off-by: Arik Hadas <aha...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java 3 files changed, 8 insertions(+), 7 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/69/35669/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java index f5980ca..ae8e5ef 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java @@ -8,6 +8,7 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; + import org.apache.commons.lang.StringUtils; import org.ovirt.engine.core.bll.context.CommandContext; import org.ovirt.engine.core.bll.job.ExecutionContext; @@ -55,7 +56,6 @@ import org.ovirt.engine.core.common.businessentities.VmPool; import org.ovirt.engine.core.common.businessentities.VmPoolType; import org.ovirt.engine.core.common.businessentities.VmRngDevice; -import org.ovirt.engine.core.common.businessentities.VmStatic; import org.ovirt.engine.core.common.businessentities.network.Network; import org.ovirt.engine.core.common.businessentities.network.VmNic; import org.ovirt.engine.core.common.businessentities.network.VnicProfile; @@ -1143,8 +1143,6 @@ */ @Override public void onPowerringUp() { - VmStatic vmStatic = getVmStaticDAO().get(getVmId()); - VmHandler.decreasePendingVms(getCurrentVdsId(), vmStatic.getNumOfCpus(), - vmStatic.getMinAllocatedMem(), vmStatic.getName()); + decreasePendingVms(getVmStaticDAO().get(getVmId())); } } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java index 01684bf..619ada1 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java @@ -28,8 +28,8 @@ import org.ovirt.engine.core.common.businessentities.LunDisk; import org.ovirt.engine.core.common.businessentities.StorageServerConnections; import org.ovirt.engine.core.common.businessentities.VDS; -import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VMStatus; +import org.ovirt.engine.core.common.businessentities.VmStatic; import org.ovirt.engine.core.common.config.Config; import org.ovirt.engine.core.common.config.ConfigValues; import org.ovirt.engine.core.common.errors.VdcBllMessages; @@ -306,8 +306,11 @@ } private void decreasePendingVms() { + decreasePendingVms(getVm().getStaticData()); + } + + protected final void decreasePendingVms(VmStatic vm) { Guid vdsId = getCurrentVdsId(); - VM vm = getVm(); if (vdsId == null || vdsId.equals(lastDecreasedVds)) { log.debug("PendingVms for the guest '{}' running on host '{}' was already released, not releasing again", vm.getName(), vdsId); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java index 0299491..dcbb4dd4 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java @@ -739,7 +739,7 @@ return validationResult; } - public static void decreasePendingVms(VM vm, Guid vdsId) { + public static void decreasePendingVms(VmStatic vm, Guid vdsId) { decreasePendingVms(vdsId, vm.getNumOfCpus(), vm.getMinAllocatedMem(), vm.getName()); } -- To view, visit http://gerrit.ovirt.org/35669 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie73f98504ae61ec20a722501fdd49930892dd80a Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <aha...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches