dlrepo: container: fix pull with k8s containerd v1 APPLIED

Julien Floret: 1
 container: fix pull with k8s containerd

 1 files changed, 8 insertions(+), 1 deletions(-)
#976337 .build.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~rjarry/dlrepo/patches/40486/mbox | git am -3
Learn more about email & git

[PATCH dlrepo] container: fix pull with k8s containerd Export this patch

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

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>
 dlrepo/views/container.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/dlrepo/views/container.py b/dlrepo/views/container.py
index 5712880a7bf4..c3653caa2dfa 100644
--- a/dlrepo/views/container.py
+++ b/dlrepo/views/container.py
@@ -112,7 +112,14 @@ class ManifestReadOnlyView(ContainerView):
        except (ValueError, KeyError) as e:
            raise errors.ManifestInvalid() from e
        if self.request.method == "HEAD":
            path = None
            return self.response(
                    "Content-Type": media_type,
                    "Content-Length": str(path.stat().st_size),
                    "Docker-Content-Digest": digest,
        return self.response(
dlrepo/patches/.build.yml: SUCCESS in 2m1s

[container: fix pull with k8s containerd][0] from [Julien Floret][1]

[0]: https://lists.sr.ht/~rjarry/dlrepo/patches/40486
[1]: mailto:julien.floret@6wind.com

✓ #976337 SUCCESS dlrepo/patches/.build.yml https://builds.sr.ht/~rjarry/job/976337
Julien Floret, Apr 19, 2023 at 17:29: