Add some logging to the registry for failure cases.
This commit is contained in:
parent
bf60862d8e
commit
39fa982ef2
1 changed files with 11 additions and 1 deletions
|
@ -43,6 +43,7 @@ def require_completion(f):
|
||||||
def wrapper(namespace, repository, *args, **kwargs):
|
def wrapper(namespace, repository, *args, **kwargs):
|
||||||
if store.exists(store.image_mark_path(namespace, repository,
|
if store.exists(store.image_mark_path(namespace, repository,
|
||||||
kwargs['image_id'])):
|
kwargs['image_id'])):
|
||||||
|
logger.warning('Image is already being uploaded: %s', kwargs['image_id'])
|
||||||
abort(400) # 'Image is being uploaded, retry later')
|
abort(400) # 'Image is being uploaded, retry later')
|
||||||
return f(namespace, repository, *args, **kwargs)
|
return f(namespace, repository, *args, **kwargs)
|
||||||
return wrapper
|
return wrapper
|
||||||
|
@ -87,6 +88,7 @@ def get_image_layer(namespace, repository, image_id, headers):
|
||||||
try:
|
try:
|
||||||
return Response(store.stream_read(path), headers=headers)
|
return Response(store.stream_read(path), headers=headers)
|
||||||
except IOError:
|
except IOError:
|
||||||
|
logger.warning('Image not found: %s', image_id)
|
||||||
abort(404) # 'Image not found', 404)
|
abort(404) # 'Image not found', 404)
|
||||||
|
|
||||||
abort(403)
|
abort(403)
|
||||||
|
@ -141,7 +143,7 @@ def put_image_layer(namespace, repository, image_id):
|
||||||
return make_response('true', 200)
|
return make_response('true', 200)
|
||||||
# We check if the checksums provided matches one the one we computed
|
# We check if the checksums provided matches one the one we computed
|
||||||
if checksum not in csums:
|
if checksum not in csums:
|
||||||
logger.debug('put_image_layer: Wrong checksum')
|
logger.warning('put_image_layer: Wrong checksum')
|
||||||
abort(400) # 'Checksum mismatch, ignoring the layer')
|
abort(400) # 'Checksum mismatch, ignoring the layer')
|
||||||
# Checksum is ok, we remove the marker
|
# Checksum is ok, we remove the marker
|
||||||
store.remove(mark_path)
|
store.remove(mark_path)
|
||||||
|
@ -168,8 +170,10 @@ def put_image_checksum(namespace, repository, image_id):
|
||||||
|
|
||||||
checksum = request.headers.get('X-Docker-Checksum')
|
checksum = request.headers.get('X-Docker-Checksum')
|
||||||
if not checksum:
|
if not checksum:
|
||||||
|
logger.warning('Missing Image\'s checksum: %s', image_id)
|
||||||
abort(400) # 'Missing Image\'s checksum')
|
abort(400) # 'Missing Image\'s checksum')
|
||||||
if not session.get('checksum'):
|
if not session.get('checksum'):
|
||||||
|
logger.warning('Checksum not found in Cookie for image: %s', image_id)
|
||||||
abort(400) # 'Checksum not found in Cookie')
|
abort(400) # 'Checksum not found in Cookie')
|
||||||
if not store.exists(store.image_json_path(namespace, repository, image_id)):
|
if not store.exists(store.image_json_path(namespace, repository, image_id)):
|
||||||
abort(404) # 'Image not found', 404)
|
abort(404) # 'Image not found', 404)
|
||||||
|
@ -287,8 +291,11 @@ def put_image_json(namespace, repository, image_id):
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
pass
|
pass
|
||||||
if not data or not isinstance(data, dict):
|
if not data or not isinstance(data, dict):
|
||||||
|
logger.warning('Invalid JSON for image: %s json: %s', image_id,
|
||||||
|
request.data)
|
||||||
abort(400) # 'Invalid JSON')
|
abort(400) # 'Invalid JSON')
|
||||||
if 'id' not in data:
|
if 'id' not in data:
|
||||||
|
logger.warning('Missing key `id\' in JSON for image: %s', image_id)
|
||||||
abort(400) # 'Missing key `id\' in JSON')
|
abort(400) # 'Missing key `id\' in JSON')
|
||||||
# Read the checksum
|
# Read the checksum
|
||||||
checksum = request.headers.get('X-Docker-Checksum')
|
checksum = request.headers.get('X-Docker-Checksum')
|
||||||
|
@ -301,11 +308,14 @@ def put_image_json(namespace, repository, image_id):
|
||||||
# We cleanup any old checksum in case it's a retry after a fail
|
# We cleanup any old checksum in case it's a retry after a fail
|
||||||
store.remove(store.image_checksum_path(namespace, repository, image_id))
|
store.remove(store.image_checksum_path(namespace, repository, image_id))
|
||||||
if image_id != data['id']:
|
if image_id != data['id']:
|
||||||
|
logger.warning('JSON data contains invalid id for image: %s', image_id)
|
||||||
abort(400) # 'JSON data contains invalid id')
|
abort(400) # 'JSON data contains invalid id')
|
||||||
parent_id = data.get('parent')
|
parent_id = data.get('parent')
|
||||||
if parent_id and not store.exists(store.image_json_path(namespace,
|
if parent_id and not store.exists(store.image_json_path(namespace,
|
||||||
repository,
|
repository,
|
||||||
data['parent'])):
|
data['parent'])):
|
||||||
|
logger.warning('Image depends on a non existing parent image: %s',
|
||||||
|
image_id)
|
||||||
abort(400) # 'Image depends on a non existing parent')
|
abort(400) # 'Image depends on a non existing parent')
|
||||||
json_path = store.image_json_path(namespace, repository, image_id)
|
json_path = store.image_json_path(namespace, repository, image_id)
|
||||||
mark_path = store.image_mark_path(namespace, repository, image_id)
|
mark_path = store.image_mark_path(namespace, repository, image_id)
|
||||||
|
|
Reference in a new issue