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 585fea6
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 520 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
39 changes: 2 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,8 @@ 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)
# return 404 in case the client is requesting docker manifest v2 schema 1
raise PathNotResolved(tag_name)

async def dispatch_tag(self, request, tag, response_headers):
"""
Expand All @@ -239,40 +238,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.

8 changes: 7 additions & 1 deletion pulp_container/tests/functional/api/test_content_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
get_auth_for_url,
)


from pulp_container.constants import MEDIA_TYPE

STANDARD_FILE_STORAGE_FRAMEWORKS = [
"django.core.files.storage.FileSystemStorage",
"pulpcore.app.models.storage.FileSystem",
Expand Down Expand Up @@ -112,7 +115,10 @@ def test_04_multiple_distributions(self):
def test_05_different_headers(self):
"""Simulate a scenario where a user queries manifests with different Accept headers."""
self.check_content(cache_status_found_func)
self.check_content(cache_status_first_func, headers={"Accept": "*/*"})
self.check_content(
cache_status_first_func,
headers={"Accept": f"{MEDIA_TYPE.INDEX_OCI},{MEDIA_TYPE.MANIFEST_LIST}"},
)

def test_06_invalidate_multiple_distributions(self):
"""Test if updating the repository referenced by multiple distributions invalidates all."""
Expand Down
Loading

0 comments on commit 585fea6

Please sign in to comment.