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
image save: make output tarball OCI compliant #44598
Conversation
|
Looks like there's some tests to adjust (or perhaps separate tests) |
|
|
||
| ociIndexFileName = "index.json" | ||
| ociLayoutFilename = "oci-layout" | ||
| ociLayoutContent = `{"imageLayoutVersion": "1.0.0"}` | ||
| ) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just use https://github.com/containerd/containerd/blob/main/images/archive/exporter.go ?
For containerd-integration mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that's the plan.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks OK to me! I made a couple minor comments, but I don't think it's anything very serious. I'm both looking forward to having/using this and to this code going away with the containerd integration. 😄
This moves the blobs around so they follow the OCI spec. Note that because docker reads paths from the manifest.json inside the tar this is not a breaking change. This does, however, remove the old layer "VERSION" file which had a big "why is this even here" in the code comments. I suspect it does not matter at all even for really old versions of Docker. In any case it is a useless file for any even relatively modern version of Docker. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
f8f7e23
to
8c5db61
Compare
| @@ -108,25 +99,6 @@ func (s *DockerCLISaveLoadSuite) TestSaveSingleTag(c *testing.T) { | |||
| assert.NilError(c, err, "failed to save repo with image ID and 'repositories' file: %s, %v", out, err) | |||
| } | |||
|
|
|||
| func (s *DockerCLISaveLoadSuite) TestSaveCheckTimes(c *testing.T) { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, these tests were incorrectly poking at the saved tarball (assuming a file location instead of looking at the manifest).
I had to do major surgery on these so I just moved them over to integration/.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went through some of the changes (but perhaps need to take another look later); left some comments / suggestions / questions inline, but overall looking 👍
| f, err := tarfs.Open(p) | ||
| assert.NilError(t, err) | ||
|
|
||
| entries, err := listTar(f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if this listTar could (not for this PR) also handled by your tar2go (fs.Glob(tarfs, "dev/*") and/or fs.WalkDir(tarfs)) 🤩
8f28912
to
0bc8bde
Compare
This makes the output of `docker save` fully OCI compliant. When using the containerd image store, this code is not used. That exporter will just use containerd's export method and should give us the output we want for multi-arch images. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
|
This is all updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| Size: int64(len(imageDescr.image.RawJSON())), | ||
| Platform: &imgPlat, | ||
| }, | ||
| Layers: foreign, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-foreign layers were accidentally dropped?
blobs/<alg>/<digest>)VERSIONfile which has no meaning and can't be used anyway in the new formatFor the new files this just goes ahead and uses OCI media types (instead of old docker types) since these are new and should not break anything.
All this works because the old docker layout is dependent on the
manifest.jsonfile at the root of the tar which has paths to each of the blobs in the tarball. The change updates the paths in the manifest to point to the new paths.This is the same technique used by buildkit to support both OCI tar formats as well as legacy docker ones.