Failed to convert a image

Bug #1603076 reported by zhangsong
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Invalid
Undecided
Unassigned

Bug Description

When I use image_utils.convert_image method to convert a image, an error occured:

>>> from cinder.image.image_utils import convert_image
>>> convert_image('image01', 'sheepdog:10.254.4.28:7000:test01', 'raw')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/cinder/image/image_utils.py", line 147, in convert_image
    out_format, run_as_root=run_as_root)
  File "/usr/lib/python2.7/site-packages/cinder/image/image_utils.py", line 121, in _convert_image
    utils.execute(*cmd, run_as_root=run_as_root)
  File "/usr/lib/python2.7/site-packages/cinder/utils.py", line 143, in execute
    return processutils.execute(*cmd, **kwargs)
  File "/usr/lib/python2.7/site-packages/oslo_concurrency/processutils.py", line 266, in execute
    cmd=sanitized_cmd)
oslo_concurrency.processutils.ProcessExecutionError: Unexpected error while running command.
Command: qemu-img convert -O raw image01 sheepdog:10.254.4.28:7000:test01
Exit code: 1
Stdout: u''
Stderr: u'qemu-img: VDI exists already, test01\nqemu-img: sheepdog:10.254.4.28:7000:test01: error while converting raw: Could not create image: Input/output error\n'

This is because the sheepdog image is already exist:
[root@controller-1 ~]# qemu-img convert -O raw image01 sheepdog:10.254.4.28:7000:test01
qemu-img: VDI exists already, test01
qemu-img: sheepdog:10.254.4.28:7000:test01: error while converting raw: Could not create
image: Input/output error

The qemu-img tool provides a '-n' option to skip the target volume creation, it works well when this option is used:
[root@controller-1 ~]# qemu-img convert -n -O raw image01 sheepdog:10.254.4.28:7000:test01
[root@controller-1 ~]#

Ceph rbd also has this problem:
[root@ceph01 ~]# qemu-img convert -O raw image01 rbd:rbd/test01
qemu-img: rbd:rbd/test01: error while converting raw: Could not create image: File exists

works well when use '-n' option:
[root@ceph01 ~]# qemu-img convert -n -O raw image01 rbd:rbd/test01
[root@ceph01 ~]#

This is not convenient in some case, such as create volume from a image. It may need to convert a image file into the volume, but the volume is created prior to running qemu-img. Here is a case in sheepdog driver, as a workaround, it need to delete the volume first, then convert the image file to the sheepdog volume, and resize the volume to original size at last:

https://github.com/openstack/cinder/blob/master/cinder/volume/drivers/sheepdog.py#L540

This is not convenient. I think it is a good way to add a optional parameter for convert_image method and add '-n' option in the final command.

zhangsong (zhangsong)
Changed in cinder:
assignee: nobody → zhangsong (zhangsong)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

Fix proposed to branch: master
Review: https://review.openstack.org/342173

Changed in cinder:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on cinder (master)

Change abandoned by Sean McGinnis (<email address hidden>) on branch: master
Review: https://review.openstack.org/342173
Reason: This review is > 4 weeks without comment, and failed Jenkins the last time it was checked. We are abandoning this for now. Feel free to reactivate the review by pressing the restore button and leaving a 'recheck' comment to get fresh test results.

Revision history for this message
Sean McGinnis (sean-mcginnis) wrote : Bug Assignee Expired

Unassigning due to no activity for > 6 months.

Changed in cinder:
assignee: zhangsong (zhangsong) → nobody
status: In Progress → New
Eric Harney (eharney)
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.