Skip to content

[Feat] Add commit compression type support #4061

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

Merged
merged 1 commit into from
May 22, 2025

Conversation

lengrongfu
Copy link
Contributor

@lengrongfu lengrongfu commented Mar 31, 2025

Fix #4060

Use zstd compression can shorten commit time. current containerd v2 having support zstd commit type, but containerd v1 version don't support.

Test case:

  1. create nginx pod, write a 5G file.
#!/bin/sh
for ((i=1; i<=5; i++))
do
  dd if=/dev/urandom of=$i".txt" bs=500M count=2
done
  1. use zstd compression to commit container only need 29s time.
$ nerdctl -n k8s.io commit ca45e0595384b14ee1fbef6f0a38efb2a2725471cb8fc143d9720a068d8b6cb1 easzlab.io.local:5000/demo/nginx:v2 --pause=true --compression=zstd

image

to view blob type.

$ nerdctl -n k8s.io image inspect --mode=native easzlab.io.local:5000/demo/nginx:v2

image

  1. use gzip compression to commit container need 2m5s time.
$ nerdctl -n k8s.io commit ca45e0595384b14ee1fbef6f0a38efb2a2725471cb8fc143d9720a068d8b6cb1 easzlab.io.local:5000/demo/nginx:v3 --pause=true

image

@apostasie
Copy link
Contributor

CI is failing right now - bustage will be fixed by #4058

@lengrongfu lengrongfu force-pushed the master branch 2 times, most recently from 9d87a91 to 6112618 Compare April 5, 2025 06:19
@lengrongfu
Copy link
Contributor Author

@yankay @AkihiroSuda please take a look, thanks.

@AkihiroSuda
Copy link
Member

CI is failing

@apostasie
Copy link
Contributor

@lengrongfu could we have a test? eg: commit with zstd, then use that image.

@lengrongfu
Copy link
Contributor Author

easzlab.io.local:5000/demo/nginx:v2

Yes, I test, can use zstd commit image to deployment pod.

@lengrongfu
Copy link
Contributor Author

lengrongfu commented May 14, 2025

@AkihiroSuda @apostasie Please take a look, thanks ~

@apostasie
Copy link
Contributor

easzlab.io.local:5000/demo/nginx:v2

Yes, I test, can use zstd commit image to deployment pod.

Thanks @lengrongfu

We need a test that can run on the CI. Eg, like in: https://github.com/containerd/nerdctl/blob/main/cmd/nerdctl/container/container_commit_test.go

@apostasie
Copy link
Contributor

apostasie commented May 14, 2025

@lengrongfu Code is fine (beside a couple of minor nits above), but my main issues right now are:

  • we need a test
  • curious if I select zstd what will happen with containerd v1?

@lengrongfu
Copy link
Contributor Author

In containerd v1 becase it don't support ocispec.MediaTypeImageLayerZstd this type , so
it will return error like unsupported diff media type https://github.com/containerd/containerd/blob/befa4ce6e99a8e8d56d1eb2e7db1d2173e1406c5/diff/walking/differ.go#L89-L94

@lengrongfu lengrongfu force-pushed the master branch 2 times, most recently from 07414b3 to 3e355e4 Compare May 14, 2025 16:17
@lengrongfu lengrongfu force-pushed the master branch 3 times, most recently from 0f5db22 to 521abab Compare May 15, 2025 09:52
@lengrongfu
Copy link
Contributor Author

@apostasie about TestZstdCommit this all test ci running success. please agaen take a look. thanks~

@apostasie
Copy link
Contributor

@apostasie about TestZstdCommit this all test ci running success. please agaen take a look. thanks~

Thanks a lot @lengrongfu !
Appreciate all the efforts here.

I do have a small series of comments here - mainly typos, and a suggestion for the test.

Let me know what you think and then it should be good for final review.

@lengrongfu lengrongfu force-pushed the master branch 2 times, most recently from 1718ad0 to 9e78423 Compare May 16, 2025 02:18
@lengrongfu
Copy link
Contributor Author

@apostasie Modified according to your suggestion, thank you for your work.

@apostasie
Copy link
Contributor

Thanks @lengrongfu

LGTM.

CI failure is unrelated.

Now to maintainers - @AkihiroSuda @yankay @fahedouch PTAL

@AkihiroSuda AkihiroSuda added this to the v2.1.2 milestone May 17, 2025
var dinf dockercompat.Info
err := json.Unmarshal([]byte(stdout), &dinf)
assert.NilError(helpers.T(), err, "failed to parse docker info")
matched, err := regexp.MatchString(`^v2\.\d+`, dinf.ServerVersion)
Copy link
Member

Choose a reason for hiding this comment

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

semver should be used

} else if sv.LessThan(semver.MustParse("1.6.0-0")) {

Copy link
Contributor Author

@lengrongfu lengrongfu May 20, 2025

Choose a reason for hiding this comment

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

done

@@ -416,3 +417,15 @@ var RemapIDs = &test.Requirement{
return false, "snapshotter does not support ID remapping"
},
}

var ContainerdVersionV2 = &test.Requirement{
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
var ContainerdVersionV2 = &test.Requirement{
func ContainerdVersion(v string) = &test.Requirement{

So that we do not need to add ContainerdVersionV2_1, ContainerdVersionV2_2, ContainerdVersionV3, ... for each of the versions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

test.Requirement is struct, how to set to func ContainerdVersion(v string)?

Copy link
Member

Choose a reason for hiding this comment

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

I meant to make it a function that returns *test.Requirement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it, thanks.

@AkihiroSuda AkihiroSuda modified the milestones: v2.1.2, v2.1.3 May 20, 2025
@lengrongfu lengrongfu force-pushed the master branch 2 times, most recently from c114e8b to 13dec2d Compare May 20, 2025 11:29
@fahedouch
Copy link
Member

fahedouch commented May 20, 2025

thanks @lengrongfu .

The documentation update is good, but it might be helpful to add a brief explanation of when to use each compression type (e.g., zstd is generally better for compression ratio but might not be as widely supported).

Copy link
Member

@fahedouch fahedouch left a comment

Choose a reason for hiding this comment

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

Thanks

@fahedouch fahedouch merged commit 694c405 into containerd:main May 22, 2025
61 of 64 checks passed
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.

container commit use compression type,eg zstd, gzip
5 participants