From 8466bb3411bb82411fe51ef86e4c0080678bf753 Mon Sep 17 00:00:00 2001 From: Mate Lakat Date: Mon, 18 Feb 2013 15:33:28 +0000 Subject: [PATCH] Fix create volume from image. Fix for bug 1129199 During creating a volume from an image, the volume status changed from creating to active, skipping the download phase. This bug was most likely introduced during: https://review.openstack.org/20514 This patch fixes the issue by change image_location back to image_id at the correct place. This patch also fixes an error in the exception handling, and the update of the volume status after creation. Change-Id: Ib9b647031c029387b776c27f9233388bd2c67e9c --- cinder/volume/manager.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 2f02a4202..5fd95f5f6 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -164,7 +164,7 @@ class VolumeManager(manager.SchedulerDependentManager): cloned = None model_update = False - if all(x is None for x in(snapshot_ref, image_location, srcvol_ref)): + if all(x is None for x in(snapshot_ref, image_id, srcvol_ref)): model_update = self.driver.create_volume(volume_ref) elif snapshot_ref is not None: model_update = self.driver.create_volume_from_snapshot( @@ -178,11 +178,12 @@ class VolumeManager(manager.SchedulerDependentManager): cloned = self.driver.clone_image(volume_ref, image_location) if not cloned: model_update = self.driver.create_volume(volume_ref) - #copy the image onto the volume. - status = 'downloading' - self.db.volume_update(context, - volume_ref['id'], - {'status': status}) + + updates = dict(model_update or dict(), status='downloading') + volume_ref = self.db.volume_update(context, + volume_ref['id'], + updates) + self._copy_image_to_volume(context, volume_ref, image_service, @@ -334,7 +335,7 @@ class VolumeManager(manager.SchedulerDependentManager): except Exception: rescheduled = False - LOG.exception(_("Error trying to reschedule"), + LOG.exception(_("Error trying to reschedule %(volume_id)s"), volume_id=volume_id) if rescheduled: -- 2.45.2