Failed to get image info

Bug #1516206 reported by zhangsong
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Invalid
Low
Unassigned
oslo-incubator
Won't Fix
Undecided
zhangsong

Bug Description

I try to use imageutils.QemuImgInfo class to get the virtual_size info of my image in cinder, The following is my usage scenarios:

source = 'sheepdog:volume-1af1afa0-7820-4063-9b90-4fa6161a74a9'
image_size = qemu_img_info(source, run_as_root=True).virtual_size

The qemu_img_info() method is defined in cinder.image.image_utils module like this:

def qemu_img_info(path, run_as_root=True):
    """Return a object containing the parsed output from qemu-img info."""
    cmd = ('env', 'LC_ALL=C', 'qemu-img', 'info', path)
    if os.name == 'nt':
        cmd = cmd[2:]
    out, _err = utils.execute(*cmd, run_as_root=run_as_root)
    return imageutils.QemuImgInfo(out)

an error occured:

2015-11-12 12:46:49.123 32474 ERROR oslo_messaging.rpc.dispatcher raise ValueError(_('Invalid input value "%s".') % details)
2015-11-12 12:46:49.123 32474 ERROR oslo_messaging.rpc.dispatcher ValueError: Invalid input value "unavailable".

But if I manually run the qemu_img info command, the virtual_size can be successfully acquired:

#qemu-img info sheepdog:volume-1af1afa0-7820-4063-9b90-4fa6161a74a9
image: sheepdog:volume-1af1afa0-7820-4063-9b90-4fa6161a74a9
file format: raw
virtual size: 10G (10737418240 bytes)
disk size: unavailable

# qemu-img info -f rbd rbd:data/foo
image: rbd:data/foo
file format: rbd
virtual size: 10G (10737418240 bytes)
disk size: unavailable
cluster_size: 4194304

This occured both in ceph and sheepdog. We can see that disk size info is unavailable, but the virtual size really exists. Why I can't get the 'virtual size' info which is really exist?

The reason is imageutils.QemuImgInfo class parse all the image info at first, it find that the disk size info doesn't matched with the setting regular expression, then it raise a ValueError, this means the image info is parsed unsuccessfully, so I can't obtain any of the info.

I think there is an mistake in imageutils.QemuImgInfo class: only the 'disk size' info is unavailable, it shouldn't raise an error when I want to get the other info.

I have tested both in sheepdog and ceph, they all show the disk_size info like 'disk size: unavailable', so I think we need to consider this as a normal scenario.

zhangsong (zhangsong)
Changed in oslo-incubator:
assignee: nobody → zhangsong (zhangsong)
zhangsong (zhangsong)
description: updated
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :

All code in oslo-incubator will be deleted soon. Please fix this up in cinder itself.

http://markmail.org/message/kgdnukenoni3hbmw

thanks,
dims

Changed in oslo-incubator:
status: New → Won't Fix
zhangsong (zhangsong)
Changed in cinder:
assignee: nobody → zhangsong (zhangsong)
Changed in cinder:
importance: Undecided → Low
Revision history for this message
Sean McGinnis (sean-mcginnis) wrote : Owner Expired

Unassigning due to no activity.

Changed in cinder:
assignee: zhangsong (zhangsong) → nobody
Revision history for this message
Sean McGinnis (sean-mcginnis) wrote :

Not sure how it was at the time this was filed, but the oslo_utils.imageutils code appears to handle this now:

https://github.com/openstack/oslo.utils/blob/master/oslo_utils/imageutils.py#L52

If not, this is actually something in the oslo_utils code, not cinder. Changes would need to be made there to address any additional handling needed.

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.