Raise the ImageTooBig exception when found it
We add the image too big error message in [1], but when we call the driver.copy_image_to_volume, if the image too big is not re-raise. So, we need raise the ImageTooBig exception when driver.copy_image_to_volume is failed due to too big image, otherwise the NOT_ENOUGH_SPACE_FOR_IMAGE message will not be recorded in [2]. [1] https://review.openstack.org/#/c/481107/ [2] https://github.com/openstack/cinder/blob/f67180d/cinder/volume/flows/manager/create_volume.py#L773-L778 Change-Id: I69767bcafe229b21d4381a704294f64b46a664d4 Closes-bug: #1798088
This commit is contained in:
parent
3ef65dfaf3
commit
a16f83b89d
@ -567,6 +567,27 @@ class ImageVolumeTestCases(base.BaseVolumeTestCase):
|
||||
# was called.
|
||||
self.assertFalse(mock_delete.called)
|
||||
|
||||
@mock.patch('cinder.image.image_utils.qemu_img_info')
|
||||
def test_create_volume_from_image_with_img_too_big(
|
||||
self, mock_qemu_info):
|
||||
"""Test create volume with ImageCopyFailure
|
||||
|
||||
This exception should not trigger rescheduling and allocated_capacity
|
||||
should be incremented so we're having assert for that here.
|
||||
"""
|
||||
image_info = imageutils.QemuImgInfo()
|
||||
image_info.virtual_size = '1073741824'
|
||||
mock_qemu_info.return_value = image_info
|
||||
|
||||
def fake_copy_image_to_volume(context, volume, image_service,
|
||||
image_id):
|
||||
raise exception.ImageTooBig(image_id=image_id, reason='')
|
||||
|
||||
self.mock_object(self.volume.driver, 'copy_image_to_volume',
|
||||
fake_copy_image_to_volume)
|
||||
self.assertRaises(exception.ImageTooBig,
|
||||
self._create_volume_from_image)
|
||||
|
||||
@mock.patch('cinder.utils.brick_get_connector_properties')
|
||||
@mock.patch('cinder.utils.brick_get_connector')
|
||||
@mock.patch('cinder.volume.driver.BaseVD.secure_file_operations_enabled')
|
||||
|
@ -528,10 +528,10 @@ class CreateVolumeFromSpecTask(flow_utils.CinderTask):
|
||||
{'volume_id': volume.id})
|
||||
raise exception.ImageUnacceptable(ex)
|
||||
except exception.ImageTooBig as ex:
|
||||
LOG.exception("Failed to copy image %(image_id)s to volume: "
|
||||
"%(volume_id)s",
|
||||
{'volume_id': volume.id, 'image_id': image_id})
|
||||
excutils.save_and_reraise_exception()
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.exception("Failed to copy image %(image_id)s to volume: "
|
||||
"%(volume_id)s",
|
||||
{'volume_id': volume.id, 'image_id': image_id})
|
||||
except Exception as ex:
|
||||
LOG.exception("Failed to copy image %(image_id)s to "
|
||||
"volume: %(volume_id)s",
|
||||
|
Loading…
x
Reference in New Issue
Block a user