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

exporter: avoid descriptor annotations on docker manifests #1730

Merged
merged 1 commit into from
Oct 20, 2020

Conversation

tonistiigi
Copy link
Member

Fixes docker/setup-buildx-action#29

Manifests with Docker media types do not define Annotations for descriptor like oci spec does. Normally registries just ignore JSON keys they don't understand but GCR is picky and produces 400 error for such manifest. This PR makes sure that annotations are never in Docker manifests and also removes the internal annotations from OCI manifests as they do not add anything to the image context.

@sipsma I believe this is a regression from GetRemote changes that now handle full descriptors.

If you hit this another workaround is to switch to oci mediatypes. -o type=image,oci-mediatypes=true,push=true

Also found another GCR issue in containerd while debugging this. If you hit 401 specifically in GCR you are probably hitting containerd/containerd#4622

Signed-off-by: Tonis Tiigi tonistiigi@gmail.com

@tonistiigi
Copy link
Member Author

Looks like this breaks TestLazyImagePush somehow? @AkihiroSuda @ktock

delete(desc.Annotations, "containerd.io/uncompressed")
delete(desc.Annotations, "buildkit/createdat")
} else {
desc.Annotations = nil
Copy link
Collaborator

@ktock ktock Oct 13, 2020

Choose a reason for hiding this comment

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

@tonistiigi Cross-repo mount fails in the test. dockerPusher doesn't support it without containerd.io/distribution.source... Annotations.

--- FAIL: TestIntegration/TestLazyImagePush/worker=containerd-1.3 (1.26s)
        client_test.go:2283: 
            	Error Trace:	client_test.go:2283
            	            				run.go:171
            	Error:      	Should be true
            	Test:       	TestIntegration/TestLazyImagePush/worker=containerd-1.3
            	Messages:   	unexpected error <nil>

https://github.com/containerd/containerd/blob/caad53dba7dbedbb5cdb95c54ec46c2d751a53e6/remotes/docker/pusher.go#L131

Configuring the exporters used in TestLazyImagePush to push OCI image (with oci-mediatypes Attr or something) makes the test happy?

Copy link
Member Author

Choose a reason for hiding this comment

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

@ktock Thanks for debug. Do you want to make a follow-up that makes oci-mediatypes=false and stargz invalid combination as they don't seem to be compatible then if annotation is required.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@tonistiigi I'm willing to contribute to this issue, but this patch doesn't seem directly related to stargz config (actually, TestLazyImagePush isn't a test for stargz images). Discarding the descriptor annotations seem to end up disabling cross-repo mounts of any types of lazyrefs (including non-stargz layers).

Roughly reading through codes around exporter/pusher, I currently think we need changes on push handlers in util/push, based on the following understanding (please tell me if I'm missing something):

For non-lazy layers, even if the layer descriptors lost annotations (this occurs by this patch), containerd.io/distribution.source... are recovered from that layer's entry stored in the content store, during (util/push).annotateDistributionSourceHandler. But lazyrefs don't have these entries in the content store so this recovery doesn't work. So we might need additional logic something like recovering distribution annotations from the original manifest (not layers) blob.

cc: @sipsma

Copy link
Member Author

Choose a reason for hiding this comment

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

@ktock You're right. We should make sure containerd.io/distribution.source do not end up in image manifests as well but if I remove them from here it would indeed disable cross-repo push as well. So we need some other way to pass annotations, not through the json.

@tonistiigi
Copy link
Member Author

Added annotations passing separately. Clean now. @sipsma @ktock

Copy link
Collaborator

@ktock ktock left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Collaborator

@sipsma sipsma left a comment

Choose a reason for hiding this comment

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

LGTM, one very minor nit, feel free to update if you agree but not a blocker in my mind at all

util/push/push.go Outdated Show resolved Hide resolved
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
@AkihiroSuda AkihiroSuda merged commit a340d41 into moby:master Oct 20, 2020
@crazy-max
Copy link
Member

crazy-max commented Oct 22, 2020

@tonistiigi Looks like it still persist (for Google Artifact Registry) with moby/buildkit:master.

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.

400 Bad Request when pushing manifest to GCR using v1.0.2
5 participants