Merge pull request #1670 from coreos-inc/blob-upload-logs

Add additional logs for invalid blob upload
This commit is contained in:
josephschorr 2016-08-02 14:55:44 -04:00 committed by GitHub
commit b662fad09e

View file

@ -284,7 +284,9 @@ def _finish_upload(namespace_name, repo_name, upload_obj, expected_digest):
# Verify that the digest's SHA matches that of the uploaded data. # Verify that the digest's SHA matches that of the uploaded data.
computed_digest = digest_tools.sha256_digest_from_hashlib(upload_obj.sha_state) computed_digest = digest_tools.sha256_digest_from_hashlib(upload_obj.sha_state)
if not digest_tools.digests_equal(computed_digest, expected_digest): if not digest_tools.digests_equal(computed_digest, expected_digest):
raise BlobUploadInvalid() logger.error('Digest mismatch for upload %s: Expected digest %s, found digest %s',
upload_obj.uuid, expected_digest, computed_digest)
raise BlobUploadInvalid(detail={'reason': 'Digest mismatch on uploaded blob'})
final_blob_location = digest_tools.content_path(expected_digest) final_blob_location = digest_tools.content_path(expected_digest)
@ -353,7 +355,7 @@ def upload_chunk(namespace_name, repo_name, upload_uuid):
def monolithic_upload_or_last_chunk(namespace_name, repo_name, upload_uuid): def monolithic_upload_or_last_chunk(namespace_name, repo_name, upload_uuid):
digest = request.args.get('digest', None) digest = request.args.get('digest', None)
if digest is None: if digest is None:
raise BlobUploadInvalid() raise BlobUploadInvalid(detail={'reason': 'Missing digest arg on monolithic upload'})
blob_upload, upload_error = _upload_chunk(namespace_name, repo_name, upload_uuid) blob_upload, upload_error = _upload_chunk(namespace_name, repo_name, upload_uuid)
blob_upload.save() blob_upload.save()