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

Docker archive auto compression #481

Merged
merged 8 commits into from
Jul 17, 2018

Conversation

mtrmac
Copy link
Collaborator

@mtrmac mtrmac commented Jul 14, 2018

DO NOT MERGE YET: Completely untested in practice.

This is based on #427 , primarily adding the code to .Close() a gzip.Reader; also with a few more tests, and some stylistic touch-ups.

@mtrmac
Copy link
Collaborator Author

mtrmac commented Jul 14, 2018

FIXME: tarfile.Source.GetBlob fails to underlyingStream.Close on error paths.

@mtrmac
Copy link
Collaborator Author

mtrmac commented Jul 16, 2018

@runcom @rhatdan PTAL. Correponding skopeo tests are in containers/skopeo#525 .

@@ -373,6 +373,12 @@ func (s *Source) GetBlob(ctx context.Context, info types.BlobInfo) (io.ReadClose
if err != nil {
return nil, 0, err
}
succeeded := false
defer func() {
if !succeeded {
Copy link
Member

Choose a reason for hiding this comment

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

Why not define return err error on the call and then just check if err != nil?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That’s elegant :) This particular method has another successful exit path (info.Digest == s.configDigest), so a bit risky.

For the same reason, the succeeded variable name is inaccurate, so I’ve at least renamed it to be right.

@rhatdan
Copy link
Member

rhatdan commented Jul 17, 2018

NIT: on error otherwise LGTM
Tests are failing.
@cyphar PTAL

mtrmac and others added 8 commits July 17, 2018 20:44
… paths

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
compression.DecompressionFunc now returns a ReadCloser; update all
its users.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
For quite a while we were blocked on support xz decompression because it
effectively required shelling out to "unxz" (which is just bad in
general). However, there is now a library -- github.com/ulikunitz/xz --
which has implemented LZMA decompression in pure Go. It isn't as
featureful as liblzma (and only supports 1.0.4 of the specification) but
it is an improvement over not supporting xz at all. And since we aren't
using its writer implementation, we don't have to worry about sub-par
compression.

Signed-off-by: Aleksa Sarai <asarai@suse.de>

(Updated to return io.ReadCloser)
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Most users of DetectCompression will use the decompressorFunc
immediately afterwards (the only exception is the copy package). Wrap
up this boilerplate in AutoDecompress, so it can be used elsewhere.

Signed-off-by: Aleksa Sarai <asarai@suse.de>

(Updated primarily to handle closing the compressed stream.)
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This matches how "docker load" deals with compressed images, as well as
being a general quality-of-life improvement over the previous error
messages we'd give. This also necessarily removes the previous
special-cased gzip handling, and adds support for auto-decompression for
streams as well.

Signed-off-by: Aleksa Sarai <asarai@suse.de>

(Updated primarily to handle closing the decompressed streams.)
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Tools like umoci will always compress layers, and in order to work
around some *lovely* issues with DiffIDs, tarfile.GetBlob would always
decompress them. However the BlobInfo returned from tarfile.GetBlob
would incorrectly give the size of the *compressed* layer because the
size caching code didn't actually check the layer size, resulting in
"skopeo copy" failing whenever sourcing umoci images.

As an aside, for some reason the oci: transport doesn't report errors
when the size is wrong...

Signed-off-by: Aleksa Sarai <asarai@suse.de>

(Updated primarily to handle closing the decompressed stream.)
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
@mtrmac mtrmac force-pushed the docker-archive-auto-compression branch from e3dfc8a to 6353fa5 Compare July 17, 2018 19:16
@mtrmac
Copy link
Collaborator Author

mtrmac commented Jul 17, 2018

Tests are failing.

make test-skopeo failures are caused by adding a dependency; they should succeed in containers/skopeo#525 after Travis gets around to running them.

@mtrmac mtrmac merged commit c6e0eee into containers:master Jul 17, 2018
@mtrmac mtrmac deleted the docker-archive-auto-compression branch July 17, 2018 23:00
@cyphar
Copy link
Contributor

cyphar commented Jul 18, 2018

LGTM. Thanks for carrying this @mtrmac. :D

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.

3 participants