Skip to content

feat: use buildkit API for clean up build cache within system prune#1360

Merged
AkihiroSuda merged 1 commit into
containerd:mainfrom
STRRL:system-prune-cleanup-cache-with-buildkit
Dec 16, 2022
Merged

feat: use buildkit API for clean up build cache within system prune#1360
AkihiroSuda merged 1 commit into
containerd:mainfrom
STRRL:system-prune-cleanup-cache-with-buildkit

Conversation

@STRRL
Copy link
Copy Markdown
Contributor

@STRRL STRRL commented Sep 7, 2022

Signed-off-by: Zhou Zhiqiang im@strrl.dev

This PR does not change the logic of nerdctl builder prune, please let me know if we should also update it.

prev #1284

close #1279

@STRRL STRRL marked this pull request as ready for review September 7, 2022 08:28
@STRRL
Copy link
Copy Markdown
Contributor Author

STRRL commented Sep 7, 2022

I think this PR is ready for review! PTAL @junnplus @AkihiroSuda @fahedouch

@STRRL
Copy link
Copy Markdown
Contributor Author

STRRL commented Sep 7, 2022

#1284 (comment)

After integrating with buildkit API directly, I noticed that the size of nerdctl increased from 29M to 32M.

But introducing buildkit API would bring some dependency issue, for example, buildkit pinned docker with github.com/docker/docker => github.com/docker/docker v20.10.3-0.20220831131523-b5a0d7a188ac+incompatible, so we also have to pin on that version. I have tried to use v20.10.7 but it failed to compile because of some API changes.

@STRRL STRRL changed the title feat: use buildkit API for clean up build cache feat: use buildkit API for clean up build cache within system prune Sep 7, 2022
@AkihiroSuda AkihiroSuda requested a review from ktock September 7, 2022 09:52
Comment thread cmd/nerdctl/system_prune.go
Comment thread cmd/nerdctl/system_prune.go Outdated
Comment thread cmd/nerdctl/system_prune.go
Comment thread pkg/infoutil/infoutil_linux.go
Comment thread cmd/nerdctl/system_prune.go
@AkihiroSuda AkihiroSuda requested a review from ktock September 26, 2022 01:46
Comment thread cmd/nerdctl/system_prune.go Outdated
Comment thread cmd/nerdctl/system_prune.go Outdated
Comment thread cmd/nerdctl/system_prune.go
@ktock
Copy link
Copy Markdown
Member

ktock commented Sep 26, 2022

needs rebase

@STRRL STRRL force-pushed the system-prune-cleanup-cache-with-buildkit branch from fc47a3e to c3083b2 Compare September 28, 2022 13:55
@STRRL
Copy link
Copy Markdown
Contributor Author

STRRL commented Sep 28, 2022

needs rebase

Updated, PTAL!

@STRRL STRRL requested review from ktock and manugupt1 and removed request for ktock and manugupt1 September 28, 2022 13:55
@STRRL STRRL force-pushed the system-prune-cleanup-cache-with-buildkit branch from af75547 to 3ce94eb Compare September 29, 2022 06:02
Comment thread cmd/nerdctl/system_prune_linux_test.go
@AkihiroSuda
Copy link
Copy Markdown
Member

Needs rebase

@STRRL STRRL force-pushed the system-prune-cleanup-cache-with-buildkit branch from a57c864 to 20e8662 Compare December 5, 2022 12:16
@STRRL
Copy link
Copy Markdown
Contributor Author

STRRL commented Dec 5, 2022

CI Windows/containerd-1.6 failed because it does not run buildkitd with windows container runtime.

What should I do? @AkihiroSuda

@STRRL STRRL force-pushed the system-prune-cleanup-cache-with-buildkit branch from 2712b5a to 31f7e87 Compare December 5, 2022 13:46
@AkihiroSuda
Copy link
Copy Markdown
Member

CI Windows/containerd-1.6 failed because it does not run buildkitd with windows container runtime.

What should I do? @AkihiroSuda

The test should be skipped when buildkitd is missing.

Also please squash commits

Comment thread go.mod Outdated
Comment thread go.mod Outdated
@STRRL
Copy link
Copy Markdown
Contributor Author

STRRL commented Dec 6, 2022

Also please squash commits

Hi @AkihiroSuda, it seems we already used "Squash and Merge" so the origin commits would not be taken in the main branch as is. Or are there any other things that I should consider?

@AkihiroSuda
Copy link
Copy Markdown
Member

AkihiroSuda commented Dec 6, 2022

it seems we already used "Squash and Merge"

Untrue. We do not use this button, as we want to keep the commits including DCO sign-off as-is

@STRRL
Copy link
Copy Markdown
Contributor Author

STRRL commented Dec 6, 2022

it seems we already used "Squash and Merge"

Untrue. We do not use this button, as we want to keep the commits including DCO sign-off as-is

Oops, got that, I would try to rebase the commits on the latest main branch.

Thanks for your explanation. ❤️

@STRRL STRRL force-pushed the system-prune-cleanup-cache-with-buildkit branch 3 times, most recently from 7beb541 to bd96b9a Compare December 6, 2022 04:59
@STRRL
Copy link
Copy Markdown
Contributor Author

STRRL commented Dec 8, 2022

Hi @AkihiroSuda, @Zheaoli, there are 2 unrelated testcase failed

  • TestRunWithJsonFileLogDriver in test-integration-rootless (22.04, main)
  • TestRunWithJsonFileLogDriver, TestRunWithJsonFileLogDriverAndLogPathOpt in test-integration-rootless (22.04, v1.6.10)

Maybe they are flaky tests, and give it a retry? PTAL, thanks!

@AkihiroSuda AkihiroSuda requested a review from ktock December 9, 2022 00:03
@AkihiroSuda AkihiroSuda added this to the v1.1.1 (tentative) milestone Dec 9, 2022
Comment thread cmd/nerdctl/system_prune_linux_test.go Outdated
base.Cmd("images").AssertNoOut("alpine")

if rootlessutil.IsRootless() {
t.Skip("test skipped for buildkitd is not available with rootless containers")
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.

Doesn't seem true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

#1360 (comment)

I remember that calling buildctl would be failed in the rootless container integration tests. So I append these lines of code.

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.

What is the error on rootless?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I remember that calling buildctl would be failed in the rootless container integration tests.

I could not reproduce that error on rootless container integration tests with my local machine now. 🙈

I would remove these lines.

@AkihiroSuda
Copy link
Copy Markdown
Member

Commits don't seem squashed

Comment thread go.mod Outdated
@STRRL
Copy link
Copy Markdown
Contributor Author

STRRL commented Dec 9, 2022

Commits don't seem squashed

Do I need to squash them into only 1 commit?

@AkihiroSuda
Copy link
Copy Markdown
Member

Commits don't seem squashed

Do I need to squash them into only 1 commit?

1 topic = 1 commit.
This doesn't necessary mean that 1 PR = 1 commit, though.

@STRRL STRRL force-pushed the system-prune-cleanup-cache-with-buildkit branch 3 times, most recently from 934b05c to 2024bae Compare December 14, 2022 07:47
Signed-off-by: Zhou Zhiqiang <im@strrl.dev>
@STRRL STRRL force-pushed the system-prune-cleanup-cache-with-buildkit branch from 2024bae to 0575de8 Compare December 14, 2022 07:49
@STRRL
Copy link
Copy Markdown
Contributor Author

STRRL commented Dec 14, 2022

I have

  • removed the testcase condiitons for rootles containers
  • squashed into 1 commit

PTAL @AkihiroSuda ❤️

Copy link
Copy Markdown
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda
Copy link
Copy Markdown
Member

BuildKit v0.11 will support buildctl du --format json, so maybe we will reopen #1284 after its GA

@AkihiroSuda AkihiroSuda merged commit 1c49ccb into containerd:main Dec 16, 2022
@STRRL
Copy link
Copy Markdown
Contributor Author

STRRL commented Dec 21, 2022

BuildKit v0.11 will support buildctl du --format json, so maybe we will reopen #1284 after its GA

So you mean we still prefer to parse the JSON output rather than importing buildkit as a library?

@AkihiroSuda
Copy link
Copy Markdown
Member

BuildKit v0.11 will support buildctl du --format json, so maybe we will reopen #1284 after its GA

So you mean we still prefer to parse the JSON output rather than importing buildkit as a library?

Yes, that might be better to avoid the replace() hell in go.mod

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.

nerdctl system prune should prune build caches too

4 participants