Roy Golan has uploaded a new change for review. Change subject: core: throw canDo if no space for stateless VM snapshots (#852647) ......................................................................
core: throw canDo if no space for stateless VM snapshots (#852647) https://bugzilla.redhat.com/852647 For each pluggable disk of stateless VM, check we have enough space to create a snapshot otherwise throw a canDo. Change-Id: Ie15cce8ded9172f37be28fd8b3d7b299628ee43e Signed-off-by: Roy Golan <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmRunHandler.java 1 file changed, 34 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/29/7929/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmRunHandler.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmRunHandler.java index 92c5ee9..c39337e 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmRunHandler.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmRunHandler.java @@ -5,6 +5,7 @@ import java.util.List; import org.apache.commons.lang.StringUtils; +import org.ovirt.engine.core.bll.command.utils.StorageDomainSpaceChecker; import org.ovirt.engine.core.bll.interfaces.BackendInternal; import org.ovirt.engine.core.bll.snapshots.SnapshotsValidator; import org.ovirt.engine.core.common.VdcActionUtils; @@ -12,6 +13,7 @@ import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.businessentities.BootSequence; import org.ovirt.engine.core.common.businessentities.Disk; +import org.ovirt.engine.core.common.businessentities.DiskImage; import org.ovirt.engine.core.common.businessentities.RepoFileMetaData; import org.ovirt.engine.core.common.businessentities.StorageDomainStatus; import org.ovirt.engine.core.common.businessentities.StorageDomainType; @@ -35,11 +37,14 @@ import org.ovirt.engine.core.dao.DiskDao; import org.ovirt.engine.core.dao.StorageDomainDAO; import org.ovirt.engine.core.dao.VmDeviceDAO; +import org.ovirt.engine.core.utils.log.Log; +import org.ovirt.engine.core.utils.log.LogFactory; import org.ovirt.engine.core.utils.vmproperties.VmPropertiesUtils; /** A utility class for verifying running a vm*/ public class VmRunHandler { private static final VmRunHandler instance = new VmRunHandler(); + private static final Log log = LogFactory.getLog(VmHandler.class); public static VmRunHandler getInstance() { return instance; @@ -149,6 +154,11 @@ message.add(VdcBllMessages.VM_CANNOT_RUN_STATELESS_HA.toString()); } + if (retValue && isStatelessVm && !hasSpaceForSnapthosts(vm)) { + retValue = false; + message.add(VdcBllMessages.ACTION_TYPE_FAILED_DISK_SPACE_LOW.name()); + } + retValue = retValue == false ? retValue : vdsSelector.CanFindVdsToRunOn(message, false); /** @@ -170,6 +180,30 @@ } /** + * check that we can create snapshots for all disks + * + * @param vm + * @return true if all storage domains have enough space to create snapshots for this VM plugged disks + */ + private boolean hasSpaceForSnapthosts(VM vm) { + for (Disk disk : getPluggedDisks(vm)) { + if (disk.isAllowSnapshot()) { + for (storage_domains domain : getStorageDomainDAO().getAllStorageDomainsByImageId(((DiskImage) disk).getImageId())) { + if (!StorageDomainSpaceChecker.hasSpaceForRequest(domain, + Config.<Integer> GetValue(ConfigValues.InitStorageSparseSizeInGB))) { + log.errorFormat("not enough space to create snapshot for disk {0} on domain {1}", + disk.getId(), + domain.getId()); + return false; + } + + } + } + } + return true; + } + + /** * Check isValid, storageDomain and diskSpace only if VM is not HA VM */ protected boolean performImageChecksForRunningVm -- To view, visit http://gerrit.ovirt.org/7929 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie15cce8ded9172f37be28fd8b3d7b299628ee43e Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Roy Golan <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
