Arik Hadas has uploaded a new change for review. Change subject: core: reduce compensation scope from hibernate command ......................................................................
core: reduce compensation scope from hibernate command This patch reduce the scope in which the compensation that is defined to switch the VM status back to UP is set in the execute stage of the hibernate vm command. The compensation context is cleared when the first task is created (in transaction) - there's no need to keep the compensation anymore since we don't want the status of the VM to switch to UP while tasks that were created as part of the hibernate command exist. Note: this is only part of the solution for the bug mentioned below. Change-Id: Iec46798fc6ea01ef6b0b4701e1af5ba616edf910 Bug-Url: https://bugzilla.redhat.com/949281 Signed-off-by: Arik Hadas <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java 1 file changed, 21 insertions(+), 16 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/10/14510/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java index 9d04ff1..0f9f1f1 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HibernateVmCommand.java @@ -1,5 +1,6 @@ package org.ovirt.engine.core.bll; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; @@ -116,7 +117,7 @@ // it for us: Guid hiberVol1 = Guid.NewGuid(); - VDSReturnValue ret1 = + final VDSReturnValue ret1 = Backend .getInstance() .getResourceManager() @@ -136,12 +137,21 @@ if (!ret1.getSucceeded()) { return; } - Guid guid1 = - createTask(ret1.getCreationInfo(), - VdcActionType.HibernateVm, - VdcObjectType.Storage, - getStorageDomainId().getValue()); - getReturnValue().getTaskIdList().add(guid1); + + TransactionSupport.executeInNewTransaction( + new TransactionMethod<Object>() { + @Override + public Object runInTransaction() { + Guid guid1 = + createTask(ret1.getCreationInfo(), + VdcActionType.HibernateVm, + VdcObjectType.Storage, + getStorageDomainId().getValue()); + getReturnValue().getTaskIdList().add(guid1); + getCompensationContext().resetCompensation(); + return null; + } + }); // second vol should be 10kb Guid image2GroupId = Guid.NewGuid(); @@ -185,9 +195,7 @@ new UpdateVmDynamicDataVDSCommandParameters(getVdsId(), getVm().getDynamicData())); - getParameters().setTaskIds(new java.util.ArrayList<Guid>()); - getParameters().getTaskIds().add(guid1); - getParameters().getTaskIds().add(guid2); + getParameters().setTaskIds(new ArrayList<Guid>(getReturnValue().getTaskIdList())); setSucceeded(true); } @@ -283,15 +291,12 @@ private void endSuccessfullyImpl() { if (getVm() != null) { if (getVm().getStatus() != VMStatus.SavingState && getVm().getStatus() != VMStatus.Up) { - // If the Vm is not in SavingState/Up status, we shouldn't - // perform Hibernate on it, - // since if the Vm is in another status, something might have - // happend to it + // If the Vm is not in SavingState status/Up, we shouldn't perform Hibernate on it, + // since if the Vm is in another status, something might have happend to it // that might prevent it from being hibernated. // NOTE: We don't remove the 2 volumes because we don't want to - // start here - // another tasks. + // start here another tasks. log.warnFormat( "HibernateVmCommand::EndSuccessfully: Vm '{0}' is not in 'SavingState'/'Up' status, but in '{1}' status - not performing Hibernate.", -- To view, visit http://gerrit.ovirt.org/14510 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iec46798fc6ea01ef6b0b4701e1af5ba616edf910 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
