[PATCH dlrepo] container: fix pull with k8s containerd (fix)
Export this patch
When responding to a HEAD request, path will be None and path.stat()
will fail. This is my fault, I tried to be a smart ass and rework
a patch from someone else before applying it.
Avoid code duplication by adding a separate dict and update it when it
is a HEAD request.
Fixes: 2850e40638be ("container: fix pull with k8s containerd")
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Julien Floret <julien.floret@6wind.com>
Applied. Release in progress. Thanks.
Thanks!
---
dlrepo/views/container.py | 14 ++++++ --------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/dlrepo/views/container.py b/dlrepo/views/container.py
index 2e8ba3d2c7fe..73ca7d8b262b 100644
--- a/dlrepo/views/container.py
+++ b/dlrepo/views/container.py
@@ -111,16 +111,14 @@ class ManifestReadOnlyView(ContainerView):
media_type = manifest["mediaType"]
except (ValueError, KeyError) as e:
raise errors.ManifestInvalid() from e
+ headers = {
+ "Content-Type": media_type,
+ "Docker-Content-Digest": digest,
+ }
if self.request.method == "HEAD":
+ headers["Content-Length"] = str(path.stat().st_size)
path = None
- return self.response(
- path=path,
- headers={
- "Content-Type": media_type,
- "Content-Length": str(path.stat().st_size),
- "Docker-Content-Digest": digest,
- },
- )
+ return self.response(path=path, headers=headers)
# --------------------------------------------------------------------------------------
--
2.40.0
dlrepo/patches/.build.yml: SUCCESS in 1m48s
[container: fix pull with k8s containerd (fix)][0] from [Robin Jarry][1]
[0]: https://lists.sr.ht/~rjarry/dlrepo/patches/40622
[1]: mailto:robin@jarry.cc
✓ #978791 SUCCESS dlrepo/patches/.build.yml https://builds.sr.ht/~rjarry/job/978791
Le lun. 24 avr. 2023 à 11:59, Robin Jarry <robin@jarry.cc> a écrit :