Skip to content

Commit

Permalink
Remove the manifest schema conversion machinery
Browse files Browse the repository at this point in the history
closes: pulp#1509
  • Loading branch information
git-hyagi committed Feb 27, 2024
1 parent 710ca3f commit d7d21ef
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 519 deletions.
2 changes: 2 additions & 0 deletions CHANGES/1509.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Removed the manifest schema conversion machinery. This change also removes the ``pyjwkest``
dependency, since it is not used anymore.
6 changes: 2 additions & 4 deletions docs/workflows/host.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,8 @@ Docker Output::

.. note::
When using a container client that cannot handle requested manifests in the new format
(schema 2), the manifests are rewritten into the old format (schema 1) on-the-fly by Pulp.
In general, the automatic conversion cannot be performed when the content is not available
in the storage. Therefore, it may be successful only if the content was previously synced
with the ``immediate`` policy.
(schema 2), the manifests will **not** be rewritten into the old format (schema 1) and Pulp will
raise a 404 (HTTPNOTFOUND) error.


Pull-Through Caching
Expand Down
43 changes: 6 additions & 37 deletions pulp_container/app/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

from pulp_container.app.cache import RegistryContentCache
from pulp_container.app.models import ContainerDistribution, Tag, Blob, Manifest, BlobManifest
from pulp_container.app.schema_convert import Schema2toSchema1ConverterWrapper
from pulp_container.app.tasks import download_image_data
from pulp_container.app.utils import (
calculate_digest,
Expand Down Expand Up @@ -212,8 +211,7 @@ async def get_tag(self, request):
}
return await self.dispatch_tag(request, tag, response_headers)

# convert if necessary
return await Registry.dispatch_converted_schema(tag, accepted_media_types, path)
raise PathNotResolved(tag_name)

async def dispatch_tag(self, request, tag, response_headers):
"""
Expand All @@ -231,6 +229,11 @@ async def dispatch_tag(self, request, tag, response_headers):
streamed back to the client.
"""
# return 404 in case the client is requesting docker manifest v2 schema 1
accepted_media_types = get_accepted_media_types(request.headers)
if accepted_media_types and accepted_media_types[0] == MEDIA_TYPE.MANIFEST_V1:
raise PathNotResolved(request.match_info["tag_name"])

try:
artifact = await tag.tagged_manifest._artifacts.aget()
except ObjectDoesNotExist:
Expand All @@ -239,40 +242,6 @@ async def dispatch_tag(self, request, tag, response_headers):
else:
return await Registry._dispatch(artifact, response_headers)

@staticmethod
async def dispatch_converted_schema(tag, accepted_media_types, path):
"""
Convert a manifest from the format schema 2 to the format schema 1.
The format is converted on-the-go and created resources are not stored for further uses.
The conversion is made after each request which does not accept the format for schema 2.
Args:
tag: A tag object which contains reference to tagged manifests and config blobs.
accepted_media_types: Accepted media types declared in the accept header.
path: A path of a repository.
Raises:
PathNotResolved: There was not found a valid conversion for the specified tag.
Returns:
:class:`aiohttp.web.StreamResponse` or :class:`aiohttp.web.Response`: The response
streamed back to the client.
"""
schema1_converter = Schema2toSchema1ConverterWrapper(tag, accepted_media_types, path)
try:
result = await sync_to_async(schema1_converter.convert)()
except RuntimeError:
raise PathNotResolved(tag.name)

response_headers = {
"Docker-Content-Digest": result.digest,
"Content-Type": result.content_type,
"Docker-Distribution-API-Version": "registry/2.0",
}
return web.Response(text=result.text, headers=response_headers)

@RegistryContentCache(
base_key=lambda req, cac: Registry.find_base_path_cached(req, cac),
auth=lambda req, cac, bk: Registry.auth_cached(req, cac, bk),
Expand Down
284 changes: 0 additions & 284 deletions pulp_container/app/schema_convert.py

This file was deleted.

Loading

0 comments on commit d7d21ef

Please sign in to comment.