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

Preserve annotations in OCI images #369

Closed
owtaylor opened this issue Jun 21, 2017 · 11 comments
Closed

Preserve annotations in OCI images #369

owtaylor opened this issue Jun 21, 2017 · 11 comments

Comments

@owtaylor
Copy link
Contributor

If you copy an OCI image to a docker registry and copy it back, then the annotations in the image should be preserved. For example, an OCI image generated by Flatpak can be found at:

https://people.gnome.org/~otaylor/example-flatpak-oci-20170621.tar.gz

There are a couple of incompatibilities with skopeo in that image:

  • It uses org.opencontainers.ref.name rather than org.opencontainers.image.ref.name (probably an older spec version)
  • The ref name it uses "app/org.gnome.eog/x86_64/master" isn't accepted by skopeo even though it looks OK by the spec

But if you fix those manually, and copy to a docker registry and copy back (I used a local registry set up with https://hub.docker.com/_/registry/), then starting with an index.json:

{
    "schemaVersion" : 2,
    "mediaType" : "application/vnd.oci.image.index.v1+json",
    "manifests" : [
    {
       "mediaType" : "application/vnd.oci.image.manifest.v1+json",
       "digest" : "sha256:0c02d6e94d7c223b4f1e67ef0a194092a67f9115293f4a5e8e5f47305057dede",
       "size" : 2067,
       "annotations" : {
           "org.flatpak.installed-size" : "4427776",
           "org.flatpak.metadata" : "[Application]\nname=org.gnome.eog\nruntime=org.fedoraproject.Platform/x86_64/26\nsdk=org.fedoraproject.Platform/x86_64/26\ncommand=eog\n\n[Context]\nshared=ipc;\nsockets=x11;wayland;session-bus;\nfilesystems=xdg-run/dconf;host;~/.config/dconf:ro;\n\n[Session Bus Policy]\nca.desrt.dconf=talk\n\n[Environment]\nDCONF_USER_CONFIG_DIR=.config/dconf\n",
            "org.opencontainers.image.ref.name" : "latest",
            "org.flatpak.download-size" : "1866664"
      }
    }
  ]
}

It ends up as:

{
"schemaVersion":2,
"manifests":[
    {
	"mediaType":"application/vnd.oci.image.manifest.v1+json",
	"digest":"sha256:0d7b52181d395460b6dbc5d336d147618424d804f8a6047e136e71ce0e181700",
	"size":348,
	"annotations":{
	    "org.opencontainers.image.ref.name":"latest"
	},"
	"platform":{
	    "architecture": "amd64",
	    "os":"linux"
	}
    }
]
}

And similarly, the annotations are also dropped from the manifest that the index points to.

@mtrmac
Copy link
Collaborator

mtrmac commented Jun 21, 2017

WRT annotations in the manifest, I think that’s expected: AFAIK none of the existing docker/distribution registries support OCI images directly, so the OCI manifest is converted into a schema2 manifest. (To be fair, right now even if a registry did support OCI, the code wouldn't try to use it; we try only schema2/schema1.) That manifest schema does not support annotations, so they are dropped during the conversion. Copying the image back to OCI/layout converts the manifest to OCI again, but the annotations are gone by then.

The annotations in the index are not even treated as a part of the OCI image in our current implementation, the “concept” of an image as currently implemented does not have any external annotations. The OCI transport only uses the index to look up a manifest file by name. (I am not really sure what the semantics of index vs. image vs. annotation is supposed to be, perhaps @runcom knows. OCI annotations just seem horribly overgeneralized to me either way.)

@mtrmac
Copy link
Collaborator

mtrmac commented Jun 21, 2017

It uses org.opencontainers.ref.name rather than org.opencontainers.image.ref.name (probably an older spec version)

Yes, containers/image#278 .

The ref name it uses "app/org.gnome.eog/x86_64/master" isn't accepted by skopeo even though it looks OK by the spec

This seems to be a bug , please file it at https://github.com/containers/image . (We may have to break the transport syntax now that an arbitrary number of : is allowed in the .tag :( )

@owtaylor
Copy link
Contributor Author

For the purposes of Flatpak, the annotations in the index.json should not needed be if the manifest is preserved. The current code might look in the index.json for them, but it can be adjusted. Does it might make sense to copy the annotations back from the manifest to the index when creating one for an oci: destination? That seems to be a question for an image spec expert. (@vbatts?)

distribution/distribution#2076 is a PR to add OCI manifest support to the docker registry. It is apparently blocked on finalizing the image spec, and also may be out of date with respect to the current image spec, but if the issue is registry-side support would hopefully allow resolving this when completed.

(@runcom asked me to file this issue to track things)

@mtrmac
Copy link
Collaborator

mtrmac commented Jun 21, 2017

(If anyone wants to experiment with OCI support in a docker/distribution registry, it should be necessary to only add the OCI manifest type to docker_image_dest.go:manifestMIMETypes; then a round-trip of an OCI image to/from the server should preserve the original manifest unmodified, or at most compress the layers if they are not compressed.)

@vbatts
Copy link
Contributor

vbatts commented Jun 30, 2017

@owtaylor preserving annotations ought to be done, but as for when they get into the index, that could vary for use-case. Presently the context of different annotations is confusing (on the index itself, or on the descriptors in the index, or on the image config itself).
For this reason it can vary the information that is wanting to be indexed.

As for the docker-registry, it is still up in the air how any of these annotations will even be exposed. I would venture to say they won't be at all. Historically community folks wanted to expose LABELS via the registry api and that never happened. But it would be very useful for projects like flatpak, because then their OCI images could re-use infrastructure like a docker registry.

@rhatdan
Copy link
Member

rhatdan commented Apr 25, 2019

@owtaylor @mtrmac @vbatts @vrothberg Is this fixed now? Can we close this issue?

@mtrmac
Copy link
Collaborator

mtrmac commented Apr 25, 2019

I don’t really think of annotations in the (manifest) “index” as part of the image (which has the manifest as the top-level object). Unless the OCI registry standard deviates from docker/distribution enough to support this extra metadata (@vbatts ?), I don’t see how we could preserve them.

@owtaylor
Copy link
Contributor Author

owtaylor commented Apr 25, 2019 via email

@mtrmac
Copy link
Collaborator

mtrmac commented Apr 25, 2019

Flatpak doesn't care any more about annotations on the index (if it ever did.) But annotations on the manifest have to be preserved. I claimed that wasn't the case in the initial description, but I think it's likely working now since we do use skopeo for uploading Flatpaks from OSBS.

Conversions from OCI to schema2 do discard annotations AFAICS; so it probably works only if the registry can natively accept OCI manifests.

@owtaylor
Copy link
Contributor Author

owtaylor commented Apr 25, 2019 via email

@mtrmac
Copy link
Collaborator

mtrmac commented Apr 25, 2019

#400 seems to be something quite irrelevant.

containers/image#400 OTOH, does involve somehow dealing with multi-arch OCI images, and that code does preserve the annotations I think. But that’s code, and functionality, that does not currently really exist, so keeping an issue filed against it does not quite make sense. So, closing.

Thanks!

@mtrmac mtrmac closed this as completed Apr 25, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants