create a volume from image failed on downloading if the volume size is smaller than the image size

Bug #1362954 reported by Chaoyi Huang
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Invalid
Undecided
Thang Pham

Bug Description

My image size is 1.5GB, and require disk space at least 4GB. When I create a volume with size to 1GB and from this image.

It failed, but failed during downloading, and only give a "error" information, nothing else.

It would be better to be failed at cinder API server like Nova to check to see if the volume size is big enough for the image.

for example, in Nova API server, :

        root_gb = instance_type['root_gb']
        if root_gb:
            if int(image.get('size') or 0) > root_gb * (1024 ** 3):
                raise exception.FlavorDiskTooSmall()

            if int(image.get('min_disk') or 0) > root_gb:
                    raise exception.FlavorDiskTooSmall()

When you boot a VM with a smaller flavor for the image, it will throw an exception to indicate what exactly happened.

Error: Flavor's disk is too small for requested image. (HTTP 400) (Request-ID: req-e4116085-0d9f-4460-858d-08d256cc97c4)

Thang Pham (thang-pham)
Changed in cinder:
assignee: nobody → Thang Pham (thang-pham)
Revision history for this message
Thang Pham (thang-pham) wrote :

I took a look at the bug. The proper checks are in place and are working. The reason you are not seeing the error message (as in nova) is that the virtual disk size is not found until after the task starts. Since the task spawned successfully, no error messages were shown.

The task essentially calls driver.copy_image_to_volume, which calls image_utils.fetch_to_volume_format. The virtual disk size is found at https://github.com/openstack/cinder/blob/master/cinder/image/image_utils.py#L225. It fails at https://github.com/openstack/cinder/blob/master/cinder/image/image_utils.py#L233.

If you look at the c-vol.log, you would clearly see the error:
File "/opt/stack/cinder/cinder/volume/flows/manager/create_vol
ume.py", line 501, in _copy_image_to_volume\n raise exception.ImageUnacceptable(ex)\n', "ImageUnacceptable:
 Image f8b0c104-d371-47b1-bff1-fbce069c9547 is unacceptable: Size is 2GB and doesn't fit in a volume of size 1
GB.\n"]

I do not believe this is something that can be fixed, since it requires you to fetch the image in order to determine the virtual disk size. Alternatively, you could put a min-disk size requirement on the image, so that an error message similar to nova's can be shown, and the command would fail before trying to fetch the image.

Changed in cinder:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.