Fix this error when pulling an image with Kubernetes/containerd:
Failed to pull image "foo":
rpc error:
code = InvalidArgument
desc = failed to pull and unpack image "foo": unable to fetch descriptor
(sha256:badcafe) which reports content size of zero: invalid argument
This is incorrect, a successful HEAD request on the image manifest
should return the size of the manifest file in the Content-Length
header, as specified in the docker registry API documentation:
The image manifest can be checked for existence with the following url:
[...]
HEAD /v2/<name>/manifests/<reference>
[...]
If the image exists and the response is successful the response will be as follows:
200 OK
Content-Length: <length of manifest>
Docker-Content-Digest: <digest>
Docker and podman do not seem to care, but containerd does.
Note that before the linked commit below, the response did not return
the content length, but neither the Docker-Content-Digest header nor
the docker media type. For some reason, it did not bother containerd
then.
Link: https://docs.docker.com/registry/spec/api/#pulling-an-image
Fixes: 63955078a3b1 ("container: fix push/pull with podman")
Signed-off-by: Julien Floret <julien.floret@6wind.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Thomas Faivre <thomas.faivre@6wind.com>