From 6439b16c04c1d36c48a802cc28d89c67a630368e Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Fri, 17 Sep 2021 16:28:13 +1000 Subject: [PATCH] Fix manifest HEAD response when looking up by label Prior change Iaf6b83b61a470e8c5a61d18b7c241f9ca002c08a contained a bug that and was returning an blank Content-Length for manifest HEAD queries. For this case, we have already read() the blob so we can just return it's length for the HEAD query. (the extant code was wrong for this case and self.storage.blob_size was returning None, which got turned into 0 silently. This leads to the client reporting: failed commit on ref "manifest-sha256:ad38c...": unexpected commit digest sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855, expected sha256:ad38c... failed precondition I put this in for anyone googling who is seeing that e3b0c4... hash; it's a clue that somehow you're trying to hash something empty. This slipped through because I tested pulling images, which worked, but it fails when pulled in by docker build). Change-Id: I7218843879ecd7939730060b6cee18af8190b888 --- zuul_registry/main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zuul_registry/main.py b/zuul_registry/main.py index 5efa367..d88b8d4 100644 --- a/zuul_registry/main.py +++ b/zuul_registry/main.py @@ -432,8 +432,7 @@ class RegistryAPI: res.headers['Docker-Content-Digest'] = manifest[ct] if method == 'HEAD': # See comment above about head response - size = self.storage.blob_size(namespace, ref) - res.headers['Content-Length'] = size + res.headers['Content-Length'] = len(data) return '' return data self.log.error('Manifest %s %s not found', repository, ref)