From 4227b128a42a1c5785ac13245de511fbcd358e37 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Wed, 11 Sep 2013 19:36:18 -0700 Subject: [PATCH] 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 --- cinder/volume/flows/create_volume/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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") % -- 2.45.2