diff --git a/CHANGES/555.bugfix b/CHANGES/555.bugfix new file mode 100644 index 000000000..043436e41 --- /dev/null +++ b/CHANGES/555.bugfix @@ -0,0 +1 @@ +Fixed 500 during image pull when content is missing on the FS. diff --git a/pulp_container/app/registry.py b/pulp_container/app/registry.py index ebfef1707..8f0658bde 100644 --- a/pulp_container/app/registry.py +++ b/pulp_container/app/registry.py @@ -62,17 +62,16 @@ async def _dispatch(file, headers): The :class:`aiohttp.web.FileResponse` for the file. """ + path = os.path.join(settings.MEDIA_ROOT, file.name) + if not os.path.exists(path): + log.warning(f"Expected path {path} is not found") + raise PathNotResolved(path) + full_headers = MultiDict() full_headers["Content-Type"] = headers["Content-Type"] full_headers["Docker-Content-Digest"] = headers["Docker-Content-Digest"] full_headers["Docker-Distribution-API-Version"] = "registry/2.0" - full_headers["Content-Length"] = str(file.size) - full_headers["Content-Disposition"] = "attachment; filename={n}".format( - n=os.path.basename(file.name) - ) - - path = os.path.join(settings.MEDIA_ROOT, file.name) file_response = web.FileResponse(path, headers=full_headers) return file_response diff --git a/pulp_container/app/schema_convert.py b/pulp_container/app/schema_convert.py index cd3a4cf89..ff0aff952 100644 --- a/pulp_container/app/schema_convert.py +++ b/pulp_container/app/schema_convert.py @@ -323,4 +323,7 @@ def _get_manifest_dict(manifest): def _get_dict(artifact): - return json.load(artifact.file) + try: + return json.load(artifact.file) + except FileNotFoundError: + raise RuntimeError()