Also include missing size attributes in layers
Docker build can in some cases omit size attributes in the layer entries in its manifests. This isn't a critical error for podman, but it does cause it not to draw the little progress arrows. So let's add them if they're missing too. Change-Id: Id5b1c5726fbe046b2f9f2994bf34f5fd7ecd90de
This commit is contained in:
parent
8f2629ed85
commit
720d091653
@ -296,20 +296,31 @@ class RegistryAPI:
|
|||||||
res.status = '201 Created'
|
res.status = '201 Created'
|
||||||
|
|
||||||
def _fix_manifest(self, namespace, content_type, body):
|
def _fix_manifest(self, namespace, content_type, body):
|
||||||
# The "docker build" commande can produce a manifest with a
|
# The "docker build" command can produce a manifest with a
|
||||||
# config that lacks a size attribute. It appears that Docker
|
# config that lacks a size attribute. It appears that Docker
|
||||||
# Hub will silently add the size, so any image fetched from
|
# Hub will silently add the size, so any image fetched from
|
||||||
# there will have it. Podman build produces image configs
|
# there will have it. Podman build produces image configs
|
||||||
# with the size attribute. The podman family of tools fails
|
# with the size attribute. The podman family of tools fails
|
||||||
# to pull images without a config size. To avoid this error,
|
# to pull images without a config size. To avoid this error,
|
||||||
# we emulate the Docker Hub behavior.
|
# we emulate the Docker Hub behavior.
|
||||||
|
# The same is true for the layer sizes, but it's not a fatal
|
||||||
|
# error; podman just doesn't draw its progress bar.
|
||||||
if (content_type ==
|
if (content_type ==
|
||||||
'application/vnd.docker.distribution.manifest.v2+json'):
|
'application/vnd.docker.distribution.manifest.v2+json'):
|
||||||
data = json.loads(body)
|
data = json.loads(body)
|
||||||
|
changed = False
|
||||||
if 'size' not in data['config']:
|
if 'size' not in data['config']:
|
||||||
digest = data['config']['digest']
|
digest = data['config']['digest']
|
||||||
size = self.storage.blob_size(namespace, digest)
|
size = self.storage.blob_size(namespace, digest)
|
||||||
data['config']['size'] = size
|
data['config']['size'] = size
|
||||||
|
changed = True
|
||||||
|
for layer in data['layers']:
|
||||||
|
if 'size' not in layer:
|
||||||
|
digest = layer['digest']
|
||||||
|
size = self.storage.blob_size(namespace, digest)
|
||||||
|
layer['size'] = size
|
||||||
|
changed = True
|
||||||
|
if changed:
|
||||||
body = json.dumps(data).encode('utf8')
|
body = json.dumps(data).encode('utf8')
|
||||||
return body
|
return body
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user