Merge pull request #1924 from coreos-inc/manifestlogs

v2: better manifest error messages
This commit is contained in:
Jimmy Zelinskie 2016-10-03 10:32:49 -04:00 committed by GitHub
commit 671dc73b82

View file

@ -100,7 +100,8 @@ def write_manifest_by_tagname(namespace_name, repo_name, manifest_ref):
try: try:
manifest = DockerSchema1Manifest(request.data) manifest = DockerSchema1Manifest(request.data)
except ManifestException as me: except ManifestException as me:
raise ManifestInvalid(detail={'message': me.message}) logger.exception("failed to parse manifest when writing by tagname")
raise ManifestInvalid(detail={'message': 'failed to parse manifest: %s' % me.message})
if manifest.tag != manifest_ref: if manifest.tag != manifest_ref:
raise TagInvalid() raise TagInvalid()
@ -118,7 +119,8 @@ def write_manifest_by_digest(namespace_name, repo_name, manifest_ref):
try: try:
manifest = DockerSchema1Manifest(request.data) manifest = DockerSchema1Manifest(request.data)
except ManifestException as me: except ManifestException as me:
raise ManifestInvalid(detail={'message': me.message}) logger.exception("failed to parse manifest when writing by digest")
raise ManifestInvalid(detail={'message': 'failed to parse manifest: %s' % me.message})
if manifest.digest != manifest_ref: if manifest.digest != manifest_ref:
raise ManifestInvalid(detail={'message': 'manifest digest mismatch'}) raise ManifestInvalid(detail={'message': 'manifest digest mismatch'})
@ -143,6 +145,7 @@ def _write_manifest(namespace_name, repo_name, manifest):
raise NameInvalid() raise NameInvalid()
if not manifest.layers: if not manifest.layers:
logger.info("manifest provided with no layers")
raise ManifestInvalid(detail={'message': 'manifest does not reference any layers'}) raise ManifestInvalid(detail={'message': 'manifest does not reference any layers'})
# Ensure all the blobs in the manifest exist. # Ensure all the blobs in the manifest exist.
@ -172,7 +175,8 @@ def _write_manifest(namespace_name, repo_name, manifest):
rewritten_image.parent_image_id, rewritten_image.parent_image_id,
) )
except ManifestException as me: except ManifestException as me:
raise ManifestInvalid(detail={'message': me.message}) logger.exception("exception when rewriting v1 metadata")
raise ManifestInvalid(detail={'message': 'failed synthesizing v1 metadata: %s' % me.message})
# Store the manifest pointing to the tag. # Store the manifest pointing to the tag.
leaf_layer_id = rewritten_images[-1].image_id leaf_layer_id = rewritten_images[-1].image_id