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

feat: Add zstd compression to crane append and mutate #1798

Closed
wants to merge 1 commit into from

Conversation

ReillyBrogan
Copy link

Support for zstd-compression was added in #1487. Add handling for this to crane append and mutate which should allow other projects that use Crane to begin creating zstd images (notably rules_oci which is used by distroless amongst other projects).

@google-cla
Copy link

google-cla bot commented Sep 28, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@ReillyBrogan ReillyBrogan force-pushed the crane-zstd-append branch 2 times, most recently from 6e60934 to 188e23b Compare September 28, 2023 15:49
@@ -90,7 +107,11 @@ func getLayer(path string, layerType types.MediaType) (v1.Layer, error) {
return stream.NewLayer(f, stream.WithMediaType(layerType)), nil
}

return tarball.LayerFromFile(path, tarball.WithMediaType(layerType))
if layerType == types.OCILayerZStd {
return tarball.LayerFromFile(path, tarball.WithMediaType(layerType), tarball.WithCompression(compression.ZStd))

Choose a reason for hiding this comment

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

I don't think this works properly. Imagine you gave it a .tar.gz file and asked for zstd compression. No re-compression will happen. You will have zstd in manifest, but contents of the blob will be gzip.

Note that there is a bug even before this PR: if one calls crane append with a zstd file, it will blindly append it with gzip in manifest.

return "Compression"
}

var ErrZStdNonOci = errors.New("ZSTD compression can only be used with an OCI base image")
Copy link

@slonopotamus slonopotamus Oct 28, 2023

Choose a reason for hiding this comment

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

This statement is not true. There exists vnd.docker.image.rootfs.diff.tar.zstd type. See moby/buildkit#2344 (comment), moby/buildkit#3968 and containerd/containerd#9263

slonopotamus added a commit to slonopotamus/go-containerregistry that referenced this pull request Oct 28, 2023
It is now possible to `crane append -f bla.tar.zstd` to upload Zstd layer, both from file and from pipe.

Before this commit, crane would erroneously upload such layer with gzip mime type.

While this PR does not _fully_ solve google#1798, it is very close to that.

Signed-off-by: Marat Radchenko <[email protected]>
@slonopotamus
Copy link

See #1827 for alternative implementation.

Copy link

This Pull Request is stale because it has been open for 90 days with
no activity. It will automatically close after 30 more days of
inactivity. Keep fresh with the 'lifecycle/frozen' label.

@slonopotamus
Copy link

No description provided.

Copy link

This Pull Request is stale because it has been open for 90 days with
no activity. It will automatically close after 30 more days of
inactivity. Keep fresh with the 'lifecycle/frozen' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants