]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix create volume from image.
authorMate Lakat <mate.lakat@citrix.com>
Mon, 18 Feb 2013 15:33:28 +0000 (15:33 +0000)
committerMate Lakat <mate.lakat@citrix.com>
Tue, 19 Feb 2013 09:45:07 +0000 (09:45 +0000)
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

index 2f02a420212ce122ae09b3a1d3dd513168497b47..5fd95f5f64e5105852df4dcca8facc997ef656e4 100644 (file)
@@ -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: