]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix handling ImageUnacceptable in create_volume
authorJay S. Bryant <jsbryant@us.ibm.com>
Mon, 12 Aug 2013 16:46:06 +0000 (11:46 -0500)
committerJay S. Bryant <jsbryant@us.ibm.com>
Mon, 12 Aug 2013 16:53:41 +0000 (11:53 -0500)
In the create_volume flow ImageUnacceptable exceptions are
not properly handled.  _copy_image_to_volume can receive an
ImageUnacceptable exception from copy_image_to_volume if fetch_to_raw
is used.  Currently the ImageUnacceptable exception is changed to
a generic ImageCopyFailure exception which does not make the cause
of the excpetion clear.

This change adds handling and raising ImageUnacceptable exceptions
in _copy_image_to_volume.  It also adds the exception to
no_reschedule_types as it doesn't make sense to keep retrying the
copy if the image was found to be unacceptable.

fixes bug 1209021

Change-Id: I9aacf23dfaaa1a4df0a869d1c9544c376488f01b

cinder/volume/flows/create_volume.py

index 702254553c3424ee8473452016d9aa6c91d427f5..af981f541d2d8bb2044dfd35a330da6a0370a89e 100644 (file)
@@ -797,6 +797,7 @@ class OnFailureRescheduleTask(CinderTask):
             exception.VolumeNotFound,
             exception.SnapshotNotFound,
             exception.VolumeTypeNotFound,
+            exception.ImageUnacceptable,
         ]
 
     def _is_reschedulable(self, cause):
@@ -1248,6 +1249,11 @@ class CreateVolumeFromSpecTask(CinderTask):
                       {'volume_id': volume_id,
                        'error': ex.stderr, 'image_id': image_id})
             raise exception.ImageCopyFailure(reason=ex.stderr)
+        except exception.ImageUnacceptable as ex:
+            LOG.error(_("Failed to copy image to volume: %(volume_id)s, "
+                        "error: %(error)s") % {'volume_id': volume_id,
+                                               'error': ex})
+            raise exception.ImageUnacceptable(ex)
         except exception.CinderException as ex:
             LOG.error(_("Failed to copy image %(image_id)s to "
                         "volume: %(volume_id)s, error: %(error)s") %