Make exception handling in get_image_metadata more specific

The generic try/except with Exception was masking an
AttributeError raised during migration flows in conductor.

This change makes the error handling specific to the translated
exceptions raised from the image service in nova.image.glance,
specifically the _translate_image_exception method.

Related-Bug: #1326926

Change-Id: I3e4db73569fc1b02d7a05b4ab10fe83fec956922
This commit is contained in:
Matt Riedemann
2014-06-18 10:55:11 -07:00
parent 7f53a8c91e
commit b1ddfdd706
2 changed files with 23 additions and 4 deletions

View File

@@ -203,7 +203,9 @@ def get_image_metadata(context, image_api, image_id_or_uri, instance):
# If the base image is still available, get its metadata
try:
image = image_api.get(context, image_id_or_uri)
except Exception as e:
except (exception.ImageNotAuthorized,
exception.ImageNotFound,
exception.Invalid) as e:
LOG.warning(_("Can't access image %(image_id)s: %(error)s"),
{"image_id": image_id_or_uri, "error": e},
instance=instance)