Add a bit better exception logging in the layer handling

This commit is contained in:
Joseph Schorr 2015-01-28 12:39:00 -05:00
parent a7ab14479e
commit 2eceb01e63

View file

@ -137,6 +137,10 @@ def get_image_layer(namespace, repository, image_id, headers):
if permission.can() or model.repository_is_public(namespace, repository):
profile.debug('Looking up repo image')
repo_image = model.get_repo_image_extended(namespace, repository, image_id)
if not repo_image:
profile.debug('Image not found')
abort(404, 'Image %(image_id)s not found', issue='unknown-image',
image_id=image_id)
profile.debug('Looking up the layer path')
try:
@ -157,7 +161,7 @@ def get_image_layer(namespace, repository, image_id, headers):
return Response(store.stream_read(repo_image.storage.locations, path), headers=headers)
except (IOError, AttributeError):
profile.debug('Image not found')
profile.exception('Image layer data not found')
abort(404, 'Image %(image_id)s not found', issue='unknown-image',
image_id=image_id)
@ -180,6 +184,7 @@ def put_image_layer(namespace, repository, image_id):
uuid = repo_image.storage.uuid
json_data = store.get_content(repo_image.storage.locations, store.image_json_path(uuid))
except (IOError, AttributeError):
profile.exception('Exception when retrieving image data')
abort(404, 'Image %(image_id)s not found', issue='unknown-image',
image_id=image_id)