From: Joshua Harlow Date: Thu, 12 Sep 2013 02:36:18 +0000 (-0700) Subject: Catch generic exceptions X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=4227b128a42a1c5785ac13245de511fbcd358e37;p=openstack-build%2Fcinder-build.git Catch generic exceptions When the driver copy_image_to_volume fails it can at the current time raise more than just CinderException as its root exception type. This causes rescheduling due to the blacklisted exception list that is used to determine if a exception is 'bad enough' to trigger rescheduling or should the volume creation action just set the volume to error state. To avoid the situation where this would cause a rescheduling we should make sure (for now) that any exception that is emitted on copying an image to a volume is translated into a image copy failure and reraised. Fixes: bug 1224211 Change-Id: Ia4a0a81d9e0967b1e7de07577d77084462304c60 --- diff --git a/cinder/volume/flows/create_volume/__init__.py b/cinder/volume/flows/create_volume/__init__.py index 391250a6f..447e8e104 100644 --- a/cinder/volume/flows/create_volume/__init__.py +++ b/cinder/volume/flows/create_volume/__init__.py @@ -1318,12 +1318,15 @@ class CreateVolumeFromSpecTask(base.CinderTask): "error: %(error)s") % {'volume_id': volume_id, 'error': ex}) raise exception.ImageUnacceptable(ex) - except exception.CinderException as ex: + except Exception as ex: LOG.error(_("Failed to copy image %(image_id)s to " "volume: %(volume_id)s, error: %(error)s") % {'volume_id': volume_id, 'error': ex, 'image_id': image_id}) - raise exception.ImageCopyFailure(reason=ex) + if not isinstance(ex, exception.ImageCopyFailure): + raise exception.ImageCopyFailure(reason=ex) + else: + raise LOG.debug(_("Downloaded image %(image_id)s (%(image_location)s)" " to volume %(volume_id)s successfully") %