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

Don't expect image sources to convert images for us #331

Closed
owtaylor opened this issue Aug 24, 2017 · 4 comments
Closed

Don't expect image sources to convert images for us #331

owtaylor opened this issue Aug 24, 2017 · 4 comments

Comments

@owtaylor
Copy link
Contributor

The point of the requestedManifestMIMETypes parameter to ImageReference.NewImageSource() is to allow the destination to affect the type of image requested from the source. It looks like the inspiration for that was that the atomic registry at one point didn't accept v2 manifests - #26 (references containers/skopeo#102 (comment))

However, that usage was effectively removed in #266, with with the idea that the if necessary, conversion happens inside containers/image when pushing to the registry.

The only reason to modify the list of mime types requested from the source, is if want the source to do the conversion rather than convert inside containers/image. But what happens inside the source is very unpredictable - it depends on the details of the source implementation, and those details may not be what we want. Examples:

  • If you pass only Accept: application/vnd.oci.image.config.v1+json to the docker registry, and what is stored is a schema2 manifest, it doesn't return the schema2 manifest unmodified, it converts it to schema1. And schema2 => schema1 => oci is going to be lower fidelity than schema2 => oci. (schema1 => oci is not even supported in containers/image at the moment though it wouldn't be hard to add as schema1 => schema2 => oci.)
  • If the source is the docker registry, and it has a signed schema2 manifest, then if you only pass Accept: application/vnd.docker.distribution.manifest.v1+json, the docker daemon happily drops the signatures, and the code in copy.Image() which is supposed to prevent conversions that drop signatures is defeated.

Concretely, for docker/distribution, the set of conversions that happen currently are quite limited:

  • schema2 manifests are converted to schema1 manifests
  • manifest lists are converted to schema2 or vchema1 manifests by extracting the manifest for a defaul tt form.

I believe that these conversions will all happen properly with containers/image and the second is a third example of why it's better to do the conversion inside containers/image - the platform should be determined by the arch of the local system, not a default platform for the registry!

If the above argument makes, sense, I can do a PR for this - either removing requestedManifestMIMETypes parameter from ImageReference.NewImageSource() - which I guess is an API change. Or just making it do nothing locally in docker_image_src.go.

@mtrmac
Copy link
Collaborator

mtrmac commented Aug 24, 2017

I agree, removing the parameter from the API does seem like the right thing to do.

One thing to note, though, is that containers/image doesn’t implement conversion from manifest lists to individual manifests; in fact copy.Image tries to detect manifest lists and refuse to work on them—and we do have a test for this—if I understand the code correctly, skopeo copy docker://some/list docker://… will set requestedManifestMIMETypes not to include manifest lists, the registry will do a conversion for us, and the copy.Image check will be defeated. Dropping requestedManifestMIMETypes will fix this to work as intended—but “as intended” means “will stop working”.

@runcom WDYT?

@owtaylor
Copy link
Contributor Author

Confusing - if a manifest list is returned by the source the code will actually go ahead and select the v2 manifest since image.FromUnparsedImage() calls manifestInstanceFromBlob which has that code, but then, yes, it looks like it fail the copy operation. The current behavior will be a mish-mash, because sometimes the manifest list type will be in the accept header and sometimes not. (Mostly not, but for the directory and oci backends, it will be listed.) So sometimes conversion happens on the server, and sometimes the copy fails.

If we switch to passing a fixed set of accept headers to the docker registry - then we have a choice of including the manifest list type or not.

@mtrmac
Copy link
Collaborator

mtrmac commented Aug 24, 2017

(apologies for the horrible run-on-sentence; as you have figured out, neutral destinations like dir: cause dockerImageSource to fetch the manifest list, and opinionated destinations like docker: ask only for s2, not s2 list, so the registry converts the image for us; the latter case breaks the logic in copy.Image to detect and refuse manifest list sources.)

@runcom
Copy link
Member

runcom commented Aug 26, 2017

We might just fix other destinations to refuse list altogether, even if we will, at some point, figure out manifest lists.
And I agree, removing the parameter from the API does seem like the right thing to do here.

owtaylor added a commit to owtaylor/image that referenced this issue Aug 31, 2017
…meter

The requestedManifestMIMETypes parameter was added because a destination
might not support all manifest MIME types that the the source supports,
but the original use case now passes all manifest types and lets
containers/image convert internally. In generally, internal conversion
may be more comprehensive, is more predictable, and avoids bypassing
internal checks.

Fixes: containers#331
owtaylor added a commit to owtaylor/image that referenced this issue Aug 31, 2017
…meter

The requestedManifestMIMETypes parameter was added because a destination
might not support all manifest MIME types that the the source supports,
but the original use case now passes all manifest types and lets
containers/image convert internally. In generally, internal conversion
may be more comprehensive, is more predictable, and avoids bypassing
internal checks.

Fixes: containers#331
owtaylor added a commit to owtaylor/image that referenced this issue Aug 31, 2017
…meter

The requestedManifestMIMETypes parameter was added because a destination
might not support all manifest MIME types that the the source supports,
but the original use case now passes all manifest types and lets
containers/image convert internally. In generally, internal conversion
may be more comprehensive, is more predictable, and avoids bypassing
internal checks.

Fixes: containers#331
owtaylor added a commit to owtaylor/image that referenced this issue Aug 31, 2017
…meter

The requestedManifestMIMETypes parameter was added because a destination
might not support all manifest MIME types that the the source supports,
but the original use case now passes all manifest types and lets
containers/image convert internally. In generally, internal conversion
may be more comprehensive, is more predictable, and avoids bypassing
internal checks.

Fixes: containers#331
Signed-off-by: Owen W. Taylor <otaylor@fishsoup.net>
owtaylor added a commit to owtaylor/image that referenced this issue Sep 2, 2017
…meter

The requestedManifestMIMETypes parameter was added because a destination
might not support all manifest MIME types that the the source supports,
but the original use case now passes all manifest types and lets
containers/image convert internally. In generally, internal conversion
may be more comprehensive, is more predictable, and avoids bypassing
internal checks.

Fixes: containers#331
Signed-off-by: Owen W. Taylor <otaylor@fishsoup.net>
@mtrmac mtrmac closed this as completed in 56b61ac Sep 7, 2017
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

No branches or pull requests

3 participants