Simone Tiraboschi has uploaded a new change for review. Change subject: iscsi: checking image size against VG free space ......................................................................
iscsi: checking image size against VG free space On block devices we are preallocating the disk image so we need to check if we have enough free space before starting. We need to validate the image size before creating the VG so we cannot simply check the VG free space but we need a rough estimate of its overhead Change-Id: I17f861a053f6ac38983967ffb07ecca9ff9b8de1 Bug-Url: https://bugzilla.redhat.com/1142710 Signed-off-by: Simone Tiraboschi <stira...@redhat.com> (cherry picked from commit 624186e372d4e80e36b60312b8b79c7a3fd2bc7d) --- M src/ovirt_hosted_engine_setup/constants.py M src/plugins/ovirt-hosted-engine-setup/storage/iscsi.py M src/plugins/ovirt-hosted-engine-setup/storage/storage.py M src/plugins/ovirt-hosted-engine-setup/vm/image.py 4 files changed, 74 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup refs/changes/51/35151/1 diff --git a/src/ovirt_hosted_engine_setup/constants.py b/src/ovirt_hosted_engine_setup/constants.py index 3bf3a4a..0daff44 100644 --- a/src/ovirt_hosted_engine_setup/constants.py +++ b/src/ovirt_hosted_engine_setup/constants.py @@ -275,6 +275,13 @@ HA_AGENT_SERVICE = 'ovirt-ha-agent' HA_BROCKER_SERVICE = 'ovirt-ha-broker' HOSTED_ENGINE_VM_NAME = 'HostedEngine' + # On block devices the VM image should be preallocated into the VG + # The VG by itself introduces some overhead that we need to take care of + # verifying the image size before creating them + # TODO get this values from VDSM APIs instead of hardcoding it + # TODO now the overhead is > 4GBiB cause we are creating a storage domain + # maybe we can do better + STORAGE_DOMAIN_OVERHEAD_GIB = 5 METADATA_CHUNK_SIZE = 4096 MAX_HOST_ID = 250 HA_NOTIF_SMTP_SERVER = 'smtp-server' @@ -528,6 +535,8 @@ ISCSI_PASSWORD = 'OVEHOSTED_STORAGE/iSCSIPortalPassword' + BDEVICE_SIZE_GB = 'OVEHOSTED_STORAGE/blockDeviceSizeGB' + @ohostedattrs( answerfile=True, ) diff --git a/src/plugins/ovirt-hosted-engine-setup/storage/iscsi.py b/src/plugins/ovirt-hosted-engine-setup/storage/iscsi.py index c85e930..04376ae 100644 --- a/src/plugins/ovirt-hosted-engine-setup/storage/iscsi.py +++ b/src/plugins/ovirt-hosted-engine-setup/storage/iscsi.py @@ -337,6 +337,9 @@ minimum=ohostedcons.Const.MINIMUM_SPACE_STORAGEDOMAIN_MB, ) ) + self.environment[ + ohostedcons.StorageEnv.BDEVICE_SIZE_GB + ] = size_mb / pow(2, 10) if self.environment[ ohostedcons.StorageEnv.VG_UUID ] is not None: diff --git a/src/plugins/ovirt-hosted-engine-setup/storage/storage.py b/src/plugins/ovirt-hosted-engine-setup/storage/storage.py index 89c1b9f..d6275c8 100644 --- a/src/plugins/ovirt-hosted-engine-setup/storage/storage.py +++ b/src/plugins/ovirt-hosted-engine-setup/storage/storage.py @@ -785,6 +785,10 @@ None ) self.environment.setdefault( + ohostedcons.StorageEnv.BDEVICE_SIZE_GB, + None + ) + self.environment.setdefault( ohostedcons.CoreEnv.ADDITIONAL_HOST_ENABLED, False ) diff --git a/src/plugins/ovirt-hosted-engine-setup/vm/image.py b/src/plugins/ovirt-hosted-engine-setup/vm/image.py index dba5863..8cfe01c 100644 --- a/src/plugins/ovirt-hosted-engine-setup/vm/image.py +++ b/src/plugins/ovirt-hosted-engine-setup/vm/image.py @@ -31,6 +31,7 @@ from ovirt_hosted_engine_setup import constants as ohostedcons +from ovirt_hosted_engine_setup import domains as ohosteddomains from ovirt_hosted_engine_setup import tasks @@ -84,6 +85,18 @@ interactive = self.environment[ ohostedcons.StorageEnv.IMAGE_SIZE_GB ] is None + + estimate_gb = None + if self.environment[ + ohostedcons.StorageEnv.BDEVICE_SIZE_GB + ] is not None: + # Conservative estimate, the exact value could be gathered from + # vginfo but at this point the VG has still has to be created. + # Later on it will be checked against the real value + estimate_gb = int(self.environment[ + ohostedcons.StorageEnv.BDEVICE_SIZE_GB + ]) - ohostedcons.Const.STORAGE_DOMAIN_OVERHEAD_GIB + valid = False while not valid: if interactive: @@ -100,7 +113,19 @@ ) try: valid = True - if int( + if estimate_gb is not None and int( + self.environment[ohostedcons.StorageEnv.IMAGE_SIZE_GB] + ) > estimate_gb: + self.logger.warning( + _( + 'Not enough free space, ' + 'about {estimate} GiB are available' + ).format( + estimate=estimate_gb + ) + ) + valid = False + if valid and int( self.environment[ohostedcons.StorageEnv.IMAGE_SIZE_GB] ) < ohostedcons.Defaults.DEFAULT_IMAGE_SIZE_GB: self.logger.warning( @@ -159,6 +184,38 @@ imgUUID = self.environment[ohostedcons.StorageEnv.IMG_UUID] volUUID = self.environment[ohostedcons.StorageEnv.VOL_UUID] serv = self.environment[ohostedcons.VDSMEnv.VDS_CLI] + + if self.environment[ohostedcons.StorageEnv.DOMAIN_TYPE] in ( + ohostedcons.DomainTypes.ISCSI, + ): + # Checking the available space on VG where + # we have to preallocate the image + vginfo = serv.s.getVGInfo( + self.environment[ohostedcons.StorageEnv.VG_UUID] + ) + self.logger.debug(vginfo) + if vginfo['status']['code'] != 0: + raise RuntimeError(vginfo['status']['message']) + vgfree = int(vginfo['info']['vgfree']) + available_gb = vgfree / pow(2, 30) + if int( + self.environment[ + ohostedcons.StorageEnv.IMAGE_SIZE_GB + ] + ) > available_gb: + raise ohosteddomains.InsufficientSpaceError( + _( + 'Error: the VG on block device has capacity of only ' + '{available_gb} GiB while ' + '{image_gb} GiB is required for the image' + ).format( + available_gb=available_gb, + image_gb=self.environment[ + ohostedcons.StorageEnv.IMAGE_SIZE_GB + ], + ) + ) + self.logger.info(_('Creating VM Image')) self.logger.debug('createVolume') volFormat = ohostedcons.VolumeFormat.RAW_FORMAT -- To view, visit http://gerrit.ovirt.org/35151 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I17f861a053f6ac38983967ffb07ecca9ff9b8de1 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-hosted-engine-setup Gerrit-Branch: ovirt-hosted-engine-setup-1.2 Gerrit-Owner: Simone Tiraboschi <stira...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches