From 45ab53ff988ff873749661dd53ac91e4cb6c1c5f Mon Sep 17 00:00:00 2001 From: taget Date: Wed, 17 May 2017 07:01:01 +0000 Subject: [PATCH] Image: Catch glance image not found exception If we run a container from a glance image uuid, zun will fail as 500 error. Fix this by catching NotFound exception while try to get image by uuid Change-Id: I0620caad085b9e4bbae9fb9a57956329826e5fc7 Closes-Bug: #1691320 --- zun/image/glance/utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/zun/image/glance/utils.py b/zun/image/glance/utils.py index 1d260f8b8..d0a9719fa 100644 --- a/zun/image/glance/utils.py +++ b/zun/image/glance/utils.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from glanceclient.common import exceptions as glance_exceptions from oslo_utils import uuidutils from zun.common import clients @@ -45,9 +46,13 @@ def find_images(context, image_ident, exact_match): glance = create_glanceclient(context) if uuidutils.is_uuid_like(image_ident): images = [] - image = glance.images.get(image_ident) - if image.container_format == 'docker': - images.append(image) + try: + image = glance.images.get(image_ident) + if image.container_format == 'docker': + images.append(image) + except glance_exceptions.NotFound: + # ignore exception + pass else: filters = {'container_format': 'docker'} images = list(glance.images.list(filters=filters))