Skip to content

Support importing docker images#2633

Merged
estesp merged 5 commits intocontainerd:masterfrom
dmcgowan:import-docker
Sep 19, 2018
Merged

Support importing docker images#2633
estesp merged 5 commits intocontainerd:masterfrom
dmcgowan:import-docker

Conversation

@dmcgowan
Copy link
Copy Markdown
Member

Updates the default image importer to support both OCI and docker image formats. OCI is always preferred when provided. This also refactors the import code to return the descriptor for an index which was placed in the content store. The docker import code will create a full OCI index with reference annotations rather than just the manfiests. The client code then creates images from the imported index. By default the index will not be retained and be garbage collected.

Updated tests are WIP, only manually tested. Can add to this PR or follow up.

@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #2633 into master will increase coverage by 1.08%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2633      +/-   ##
==========================================
+ Coverage   44.05%   45.13%   +1.08%     
==========================================
  Files          94       92       -2     
  Lines       10238     9976     -262     
==========================================
- Hits         4510     4503       -7     
+ Misses       5008     4754     -254     
+ Partials      720      719       -1
Flag Coverage Δ
#linux 48.95% <ø> (+1.18%) ⬆️
#windows 41.86% <ø> (+1.13%) ⬆️
Impacted Files Coverage Δ
images/oci/exporter.go

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 83668f4...fe9a8bf. Read the comment docs.

Comment thread images/docker/importer.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Addressed

@dmcgowan
Copy link
Copy Markdown
Member Author

Simplified the code quite a bit based on Tonis' feedback about only needing to get the layout structure from manifest.json. Now every file is treated as blob except the manifest.json and OCI layout file, any symlink is supported since they are only used to dereference the blob digest.

Comment thread images/oci/importer.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we still want to keep oci importer?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Maybe not, at first the Docker one was pretty complicated compared to OCI

@dmcgowan
Copy link
Copy Markdown
Member Author

This PR is depending on #2642 to fix a bug I found while testing this

Allow customization of reference creation.
Add option for digest references.

Signed-off-by: Derek McGowan <[email protected]>
Update ctr to support all formats by default

Signed-off-by: Derek McGowan <[email protected]>
Support any layout and rely on manifest.json to reference blobs

Signed-off-by: Derek McGowan <[email protected]>
@dmcgowan dmcgowan force-pushed the import-docker branch 2 times, most recently from ae8d39c to 25dbce4 Compare September 14, 2018 22:27
Comment thread cmd/ctr/commands/images/import.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

likely/recommended to contain only tags, but IIUC it is also valid to include the base image name?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And we should have tests (can be a separate PR)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated to say it may contain it, I think we should be exporting with the base name otherwise there is important information which gets excluded.

Comment thread images/bundle/importer.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: I would expect "bundle" to mean OCI runtime bundle (config.json + rootfs)

Maybe we can call this package just "oci"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Do we use any other term to represent this tar archive? I don't think oci is the right package name here, it is a subset of the OCI functionality and now includes functionality which is not OCI.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I am going to just rename it to archive, I was trying to avoid overloading that package name but I think that is the most correct package name, since it is an image archive.

Comment thread images/bundle/reference.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

reference -> cri/util ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This ends up importing from github.com/docker/distribution/reference which I want to avoid using

Comment thread cmd/ctr/commands/images/import.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

date -> yyyy-MM-dd ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we mention that the default platform will be assigned?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was trying to avoid platform related stuff in this PR, platform options should definitely be included as well as the option to not unpack.

Comment thread cmd/ctr/commands/images/import.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/s/,oci-name//

Comment thread cmd/ctr/commands/images/import.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe add "(default: false)"

Comment thread images/bundle/importer.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The OCI spec says this is REQUIRED https://github.com/opencontainers/image-spec/blame/master/image-layout.md#L24, I'd at least pop out a warning message if it's empty, if not an error.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It is REQUIRED which is why when it does not exist the content gets interpreted as in the Docker format. I could make this more clear in the code.

Comment thread images/bundle/importer.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ok.. but which platform? should it be the first or the matching.. hmm

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This comment is trying to say that only a manifest list can resolve to multiple platforms and the descriptor is explicitly not a manifest list. When it is just a manifest, the platform gets resolved from the config which can only have a single platform.

Copy link
Copy Markdown
Member

@mikebrow mikebrow Sep 17, 2018

Choose a reason for hiding this comment

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

kk so the > 0 was a no panic check.. should it be a warning or error if > 1 || < 1 here? or is this just an optional overwrite to the default...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The resolve can be 0 or 1, not too concerned about >1 since the descriptor was created above in a way where it can never be >1

Comment thread images/bundle/importer.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit /msft/mfst/

@estesp estesp added this to the 1.2 milestone Sep 17, 2018
Signed-off-by: Derek McGowan <[email protected]>
Signed-off-by: Derek McGowan <[email protected]>
Copy link
Copy Markdown
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

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

/LGTM with travis fix..

@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #2633 into master will increase coverage by 0.87%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2633      +/-   ##
==========================================
+ Coverage   43.88%   44.75%   +0.87%     
==========================================
  Files          94       92       -2     
  Lines       10307    10164     -143     
==========================================
+ Hits         4523     4549      +26     
+ Misses       5067     4898     -169     
  Partials      717      717
Flag Coverage Δ
#linux 48.71% <0%> (+1.17%) ⬆️
#windows 41.68% <0%> (+1.12%) ⬆️
Impacted Files Coverage Δ
content/helpers.go 22.64% <0%> (ø) ⬆️
oci/spec_opts.go 22.28% <0%> (+0.92%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d09a1c6...da6d290. Read the comment docs.

Copy link
Copy Markdown
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

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

LGTM

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.

6 participants