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

Fixed blob media_type during image push. #414

Merged
merged 1 commit into from
Nov 16, 2021
Merged

Conversation

ipanova
Copy link
Member

@ipanova ipanova commented Oct 8, 2021

closes #9229

@ipanova ipanova marked this pull request as draft October 8, 2021 14:16
@pulpbot
Copy link
Member

pulpbot commented Oct 8, 2021

Attached issue: https://pulp.plan.io/issues/9229

@ipanova ipanova force-pushed the i9229 branch 3 times, most recently from a41449b to f2fc944 Compare October 11, 2021 13:45
@ipanova ipanova marked this pull request as ready for review October 12, 2021 22:38
):
raise BlobInvalid(digest=config_blob.digest)
config_blob.media_type = config_media_type
config_blob.save()
Copy link
Member

Choose a reason for hiding this comment

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

I'd really prefer if we didn't update existing content units.

thru.append(models.BlobManifest(manifest=manifest, manifest_blob=blob))
models.BlobManifest.objects.bulk_create(objs=thru, ignore_conflicts=True, batch_size=1000)
models.Blob.objects.bulk_update(objs=blobs_qs, fields=["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.

The same here. Is there a way to have the Blob content type available when creating the blob?

Copy link
Member Author

Choose a reason for hiding this comment

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

Tthe client does not send any information regarding that and since blobs come first and manifest as last i don't see any other way then updating the content post creation. I agree with you though, this is not my preferred way but at least we're not changing any foreign keys like we did with tags

Copy link
Member

Choose a reason for hiding this comment

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

Are we sure that the same binary blob can only ever be used with the same content-type? (Can it be CONFIG_BLOG in one and CONFIG_BLOG_OCI in another repo?)
If not we can either create a new Blob with the proper content-type (adding the latter to the natural key), or we would need to be even more clever at delivering the content injecting the type there.

Copy link
Member Author

Choose a reason for hiding this comment

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

When it comes to docker, I can almost never say things with 100% certainty.
While there is a full compatibility between blobs docker and oci media_types https://github.com/opencontainers/image-spec/blob/main/media-types.md#applicationvndociimagelayerv1targzip , having set regular blob type in the config blob is quite wrong.
For the config blobs, they are very similar https://github.com/opencontainers/image-spec/blob/main/media-types.md#applicationvndociimageconfigv1json I'd expect the digest to change since some of the fields are not used in the OCI format.

Copy link
Member Author

@ipanova ipanova Oct 18, 2021

Choose a reason for hiding this comment

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

I have an idea, I need to check it out 💡

Copy link
Member Author

Choose a reason for hiding this comment

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

we can also use https://github.com/ahupp/python-magic to identify the file type but that's adding a dependency

I looked into the code and unfortunately they do not distinguish between gzipped blob and json blob which looks more like a bug to me https://github.com/containers/image/blob/main/docker/docker_image_dest.go#L171

@ipanova ipanova marked this pull request as draft October 18, 2021 21:07
@ipanova ipanova force-pushed the i9229 branch 3 times, most recently from 0a92af6 to c4b0902 Compare October 19, 2021 18:20
@ipanova ipanova force-pushed the i9229 branch 2 times, most recently from 6e60fce to dc52145 Compare November 15, 2021 22:26
@@ -0,0 +1 @@
Fixed blob media_type during image push.
Copy link
Member Author

Choose a reason for hiding this comment

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

@mdellweg I am not sure what to do with it. I learned that the blob_media_type is not important to client at all, instead it cares about the content_type returned, which I've fixed.
I suggest to remove this changelog entry from the PR and deal with 9229 separately - not sure how, we can probably keep blob.media_type field on the model but treat it as informative only, or deprecate entirely.

Copy link
Member

Choose a reason for hiding this comment

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

If all the bugs are fixed without that, we should remove it and get the rest shipped.
When we realize that we really ignore the media_type field, we can remove it eventually. But if we can keep that migration out of this PR, we get more flexibility for backports. Right?

Copy link
Member Author

Choose a reason for hiding this comment

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

exactly

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.

3 participants