projectatomic / atomic

Atomic Run Tool for installing/running/managing container images.
Other
526 stars 140 forks source link

Labels are not always parsed correctly #1173

Open ashcrow opened 6 years ago

ashcrow commented 6 years ago

A user following the Openshift Ansible instructions was unable to use the run_once functionality. After digging into the code a bit I found that _inspect_system_branch(..) loads the manifest and assumes it will have the labels:

        labels = {}
        manifest = self._image_manifest(repo, commit_rev)
        virtual_size = None
        if manifest:
            manifest = json.loads(manifest)
            virtual_size = self._get_virtual_size(repo, manifest)
            if 'Labels' in manifest:
                labels = manifest['Labels']
            image_id = SystemContainers._get_image_id(repo, commit_rev, manifest) or image_id

However, the manifest may not have the labels. The manifest output for the openshift ansible image renders as such:

{"schemaVersion":2,"mediaType":"application/vnd.docker.distribution.manifest.v2+json","config":{"mediaType":"application/vnd.docker.container.image.v1+json","size":4335,"digest":"sha256:45abc081093b825a638ec53a19991af0612e96e099554bbdfa88b341cdfcd2e6"},"layers":[{"mediaType":"application/vnd.docker.image.rootfs.diff.tar.gzip","size":74876245,"digest":"sha256:9cadd93b16ff2a0c51ac967ea2abfadfac50cfa3af8b5bf983d89b8f8647f3e4"},{"mediaType":"application/vnd.docker.image.rootfs.diff.tar.gzip","size":1239,"digest":"sha256:4aa565ad8b7a87248163ce7dba1dd3894821aac97e846b932ff6b8ef9a8a508a"},{"mediaType":"application/vnd.docker.image.rootfs.diff.tar.gzip","size":154068365,"digest":"sha256:7952714329657fa2bb63bbd6dddf27fcf717186a9613b7fab22aeb7f7831b08a"}]}

Using skopeo inspect --raw on the image shows the information in question is stored in history[0].v1Compatibility.

Looking at self.get_manifest(..) I was hoping we could grab the data but it looks like the same issue exists there. When attempting to pull the remote manifest the labels don't come down either.

ashcrow commented 6 years ago

/cc @giuseppe

giuseppe commented 6 years ago

Fixed with: https://github.com/projectatomic/atomic/pull/1170 @baude is cutting a new release that will contain the fix