docker-registry icon indicating copy to clipboard operation
docker-registry copied to clipboard

Can a checksum be pushed before uploading the layer ?

Open noteed opened this issue 11 years ago • 0 comments

Hi,

Using docker 1.1.2 and the registry image 0.8.0.

I'm playing around with the registry protocol and I generated a 500 doing this (note the image doesn't exist yet on the server).

  1. Upload an image meta-data (i.e. to the /json route),
  2. Try uploading an image checksum (i.e. to the /checksum route).

Doing 2. alone will just do a 404. Doing 1. and 2. generates this traceback:

2014-08-18 11:04:41,976 ERROR: Exception on /v1/images/non-existing-1/checksum [PUT]
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python2.7/dist-packages/docker_registry/toolkit.py", line 250, in wrapper
    return f(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/docker_registry/images.py", line 285, in put_image_checksum
    checksums = load_checksums(image_id)
  File "/usr/local/lib/python2.7/dist-packages/docker_registry/images.py", line 373, in load_checksums
    data = store.get_content(checksum_path)
  File "/usr/local/lib/python2.7/dist-packages/docker_registry/drivers/file.py", line 55, in get_content
    raise exceptions.FileNotFoundError('%s is not there' % path)
FileNotFoundError: /tmp/registry/images/non-existing-1/_checksum is not there

I.e. the server assumes that when the checksum is pushed, it means the layer has already been pushed and thus a computed checksum file is already available.

Related to this checksum upload and comparison against the server-side computed checksum, I would like to know what should happen if the comparison fails. Currently the server does a 400 "Checksum mismatch". Shouldn't it also delete the image layer ? Or what is the point of uploading the checksum if the server thinks the layer is good (and its computed checksum the right one) ?

noteed avatar Aug 18 '14 11:08 noteed