Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the manifest schema conversion machinery #1529

Merged

Conversation

git-hyagi
Copy link
Contributor

closes: #1509

@git-hyagi git-hyagi force-pushed the remove-manifest-schema-conversion-machinery branch 2 times, most recently from aa81c74 to 9582ef9 Compare February 26, 2024 19:32
@@ -2,3 +2,4 @@ mock
pytest-django
pulp-smash @ git+https://github.com/pulp/pulp-smash.git
pytest<8
pyjwkest>=1.4,<=1.4.2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum... I probably had issues before removing the test_convert.py file:
https://github.com/pulp/pulp_container/pull/1529/files#diff-2f5092e427a2a7997e2ce75c8c252cbd9d3d30b33f2ab32dbe1b241194de98bdL6
I just tried again without it and had no dependency errors. Removing it.

@@ -186,6 +192,11 @@ def fetch_response_metadata(self, response):
if DEFAULT_FILE_STORAGE in STANDARD_FILE_STORAGE_FRAMEWORKS:
return response.status_code, response.headers.get("X-PULP-CACHE")
else:
"""Corner case for deprecated v2 schema1"""
Copy link
Member

@lubosmj lubosmj Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which corner cases are we catching here? I thought that we were dealing only with manifest v2 schema 2 content inside this test case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember now, but it was probably an error in test_05_different_headers.
I'm rerunning the tests without this block to confirm that the "corner case" was actually because of wrong headers in my tests.

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this part is not required inside dispatch_tag. How about we remove the code and add the highlighted comment just above the raise PathNotResolved call placed at the end of the get_tag method? So, we will not forget about the rationale behind raising the exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this part is not required inside dispatch_tag.

Agreed. I added this part when I was having issues with the test_05_different_headers and setting "wrong headers". I'm rerunning the tests without this modification in dispatch_tag and will check if the tests will pass.

How about we remove the code and add the highlighted comment just above the raise PathNotResolved call placed at the end of the get_tag method? So, we will not forget about the rationale behind raising the exception.

Good idea!

@git-hyagi git-hyagi force-pushed the remove-manifest-schema-conversion-machinery branch from 9582ef9 to 585fea6 Compare February 27, 2024 11:53
@ipanova
Copy link
Member

ipanova commented Feb 27, 2024

you forgot about redirects.py file, we should not 302-->404 but raise 404 right away

@@ -0,0 +1,2 @@
Removed the manifest schema conversion machinery. This change also removes the ``pyjwkest``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we expand more on what it means?
e.g. Removed the manifest schema conversion machinery. If the manifest is stored locally in the newer format and old clients request v2 schema1 manifest they will receive 404.
v2 schema1 manifest is still going to be mirrored from remote source during sync if available and passed to the old clients on the request.

@git-hyagi git-hyagi force-pushed the remove-manifest-schema-conversion-machinery branch from 585fea6 to eba4735 Compare February 27, 2024 18:38
Comment on lines 391 to 393
if media_type == MEDIA_TYPE.MANIFEST_V1:
raise ManifestNotFound(reference=pk)

Copy link
Member

@lubosmj lubosmj Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a manifest's media type is MEDIA_TYPE.MANIFEST_V1, we should not raise ManifestNotFound. Instead, let's return the manifest because we have got the same media type as requested by a user. Also, the media_type variable can contain comma separated values.

@@ -962,6 +970,9 @@ def get(self, request, path, pk):
@RegistryApiCache(base_key=lambda req, cac: find_base_path_cached(req, cac))
def handle_safe_method(self, request, path, pk):
"""Handles safe requests for Blobs."""
# Fail early in case of unsupported manifest schemas
self.handle_old_manifest_version(request.accepted_media_type, pk)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not care about media types when it comes to blobs. You can safely remove this check here.

@git-hyagi git-hyagi force-pushed the remove-manifest-schema-conversion-machinery branch from eba4735 to a30f1d9 Compare February 28, 2024 16:57
manifest_media_type not in get_accepted_media_types(self.request.headers)
and manifest_media_type != MEDIA_TYPE.MANIFEST_V1
):
raise Http404("Unsupported manifest version: %s" % manifest_media_type)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried raising ManifestNotFound instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hum....not yet after this change.
I'll try it!

format and old clients request v2 schema1 manifest they will receive 404. v2 schema1 manifest is
still going to be mirrored from remote source during sync if available and passed to the old clients
on the request.
This change also removed the ``pyjwkest`` dependency, since it is not used anymore.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if this dependency removal is necessary to announce. @ipanova, what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree.

@git-hyagi git-hyagi force-pushed the remove-manifest-schema-conversion-machinery branch from a30f1d9 to 68c7b91 Compare February 29, 2024 11:16
Comment on lines 38 to 47
def issue_tag_redirect(self, tag, pk):
"""
Issue a redirect for the passed tag.
"""
manifest_media_type = tag.tagged_manifest.media_type
if (
manifest_media_type not in get_accepted_media_types(self.request.headers)
and manifest_media_type != MEDIA_TYPE.MANIFEST_V1
):
raise ManifestNotFound(reference=pk)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to use tag.name instead? If so, there is no need to have a an additional argument.

Copy link
Member

@lubosmj lubosmj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you update the staging variant of the documentation, please?

staging_docs/user/tutorials/01-sync-and-host.md

@git-hyagi git-hyagi force-pushed the remove-manifest-schema-conversion-machinery branch 2 times, most recently from cb6dcc4 to 8958ff7 Compare February 29, 2024 20:35
@@ -60,7 +68,8 @@ class S3StorageRedirects(CommonRedirects):

def issue_tag_redirect(self, tag):
"""
Issue a redirect or perform a schema conversion if an accepted media type requires it.
Issue a redirect if an accepted media type requires it or return not found if manifest
version is not supported.
Copy link
Member

@ipanova ipanova Mar 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your changes are not really related but i noticed and think that we should swap the if/elif branches because if we got schema1 we will not return signed schema as we should

@git-hyagi git-hyagi force-pushed the remove-manifest-schema-conversion-machinery branch from 8958ff7 to 8b18ecd Compare March 1, 2024 12:18
Copy link
Member

@ipanova ipanova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good,thanks!

@ipanova
Copy link
Member

ipanova commented Mar 1, 2024

@lubosmj
Copy link
Member

lubosmj commented Mar 1, 2024

@lubosmj seems like pull-through tests is failing on azure, a fluke? https://github.com/pulp/pulp_container/actions/runs/8111223816/job/22170105281?pr=1529#step:14:2184

I have noticed this. It started failing a couple weeks ago. It might be related to #1493 or artifacts/content being already present in the storage and there is a race condition. I will open an issue for that next week if it occurs again.

@ipanova
Copy link
Member

ipanova commented Mar 1, 2024

or artifacts/content being already present in the storage and there is a race condition.

This is test of pull operation and not push, so no.

@lubosmj
Copy link
Member

lubosmj commented Mar 1, 2024

Yes, the error is the same as noted in the aforementioned issue:

    raise NotImplementedError("Redirecting to this storage is not implemented.")

@lubosmj lubosmj merged commit 9c0919f into pulp:main Mar 1, 2024
15 of 16 checks passed
@git-hyagi git-hyagi deleted the remove-manifest-schema-conversion-machinery branch March 1, 2024 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove the manifest schema conversion machinery
3 participants