Create volume from image does not convert with ceph

Bug #1247998 reported by Matt Edlefsen on 2013-11-05
42
This bug affects 8 people
Affects Status Importance Assigned to Milestone
Cinder
High
Dmitry Borodaenko

Bug Description

When creating a volume from image using the RBD backend for cinder, the image will be copied directly and not converted even if the image is not raw (e.g. qcow2). This causes mounting and booting to fail as the volume is not raw.

The problem, I think, is in clone_image in the RBD volume driver, which doesn't check the type of the source image and doesn't convert it. It is called from CreateVolumeFromSpecTask#_create_from_image. Implementations of clone_image for other drivers seem to do the conversion correctly.

Matt Edlefsen (matt-edlefsen) wrote :

Couple of additional notes:

This is on a fully updated ubuntu 13.10 install with openstack 1:2013.2-0ubuntu1.

At least on the latest ubuntu, qemu-img supports rbd: paths in qemu-img info and convert. The easiest solution then I think would be to check the image type using qemu-img info and just "return None, False" if it isn't raw.

It could also do the conversion without temp files by passing rbd: paths to qemu-img convert. Somewhat oddly though on my system exporting to a temp file, doing qemu-img convert, and then importing back into rbd is about twice as fast as doing qemu-img convert directly with rbd paths.

The other feature that would be useful would be creating a "shadow" copy of the image that is in raw form so that multiple volumes cloned from the same image could take advantage of COW even for non-raw images (qcow2 seems to be what most things are available for download in).

I might take a crack at implementing this but I'll need to setup a dev version of openstack first :/

tags: added: ceph-rbd drivers
Haomai Wang (haomai) wrote :

I think this bug isn't exist in the newest Cinder codes

Mike Perez (thingee) wrote :

Yes it does. Currently RBD expects the image to be in the right format.

Edward Hope-Morley (hopem) wrote :

Hmm this should not be the case. The rbd driver currently enforces conversion to raw when doing a create volume from image:

https://github.com/openstack/cinder/blob/master/cinder/volume/drivers/rbd.py#L745

Matt Edlefsen (matt-edlefsen) wrote :

I don't believe copy_image_to_volume is ever called. _create_from_image (#1) calls clone_image (#2) and trusts that if implemented it will check the image type. At least some other drivers (#3) do this check and handle non-raw images.

1) https://github.com/openstack/cinder/blob/master/cinder/volume/flows/create_volume/__init__.py#L1443
2) https://github.com/openstack/cinder/blob/master/cinder/volume/drivers/rbd.py#L726
3) https://github.com/openstack/cinder/blob/master/cinder/volume/drivers/gpfs.py#L510

Josh Durgin (jdurgin) wrote :

Yes, the issue is that the rbd driver's clone_image() should return ({}, False) if it encounters a non-raw image. I think the best fix is to add the image type (whatever glance says it is) as another argument to clone_image(), and for rbd check that the type is raw, otherwise return ({}, False) so that the flow falls back to doing a full copy (with conversion) via copy_volume_from_image().

Changed in cinder:
importance: Undecided → High
Edward Hope-Morley (hopem) wrote :

Ah good catch, this is specifically for the case where a COW clone is possible (glance v2 api is used) and the image (rbd) being cloned is non-raw. Should have a patch up imminently.

Changed in cinder:
status: New → In Progress
assignee: nobody → Edward Hope-Morley (hopem)
Changed in cinder:
assignee: Edward Hope-Morley (hopem) → Dmitry Borodaenko (dborodaenko)
tags: added: ceph rbd
removed: ceph-rbd

Reviewed: https://review.openstack.org/58870
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=e066158b5235a3879fe90fa3bd813fc3363c01f5
Submitter: Jenkins
Branch: master

commit e066158b5235a3879fe90fa3bd813fc3363c01f5
Author: Dmitry Borodaenko <email address hidden>
Date: Wed Nov 27 14:33:00 2013 -0800

    Do not clone non-raw images in rbd backend

    RBD backend only supports booting from images in raw format. A volume
    that was cloned from an image in any other format is not bootable. The
    RBD driver will consider non-raw images to be uncloneable to trigger
    automatic conversion to raw format.

    Includes conversion of the corresponding unit test to use mock (instead
    of mox) and expanded comments and error messages based on change #58893
    by Edward Hope-Morley.

    Change-Id: I5725d2f7576bc1b3e9b874ba944ad17d33a6e2cb
    Closes-Bug: #1246219
    Closes-Bug: #1247998

Changed in cinder:
status: In Progress → Fix Committed
Thierry Carrez (ttx) on 2014-01-22
Changed in cinder:
milestone: none → icehouse-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx) on 2014-04-17
Changed in cinder:
milestone: icehouse-2 → 2014.1
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers