nerdctl icon indicating copy to clipboard operation
nerdctl copied to clipboard

feat: system prune also cleanup build cache

Open STRRL opened this issue 1 year ago • 15 comments

Signed-off-by: Zhou Zhiqiang [email protected]

close https://github.com/containerd/nerdctl/issues/1279

Changes:

  • call builderPruneAction() within command system prune

STRRL avatar Jul 31 '22 03:07 STRRL

PTAL!

@Zheaoli @AkihiroSuda

STRRL avatar Jul 31 '22 03:07 STRRL

Signed-off-by: STRRL

Thanks, but please use real name

AkihiroSuda avatar Jul 31 '22 04:07 AkihiroSuda

Signed-off-by: STRRL

Thanks, but please use real name

Updated!

STRRL avatar Jul 31 '22 08:07 STRRL

Hi @AkihiroSuda @junnplus , I meet some trouble when using TabReader to parse the output of buildctl prune.

The output of the buildctl prune is not soo standard, it would use both \t and white-space as the delimiter:

image

I also updated the testcase, so it would be failed with the current TabReader implementation because it extracts values based on the character position.

STRRL avatar Aug 03 '22 12:08 STRRL

What should I do now? Make a new implementation like TabReader but only for buildctl prune? or wait https://github.com/moby/buildkit/pull/2992 getting merged?

STRRL avatar Aug 03 '22 12:08 STRRL

What should I do now? Make a new implementation like TabReader but only for buildctl prune? or wait moby/buildkit#2992 getting merged?

I just noticed that PR already get merged! :tada:

I think I could update code based on the json output!

STRRL avatar Aug 03 '22 12:08 STRRL

I think I could update code based on the json output!

Are we not compatible with older versions?

junnplus avatar Aug 03 '22 12:08 junnplus

I think I could update code based on the json output!

Are we not compatible with older versions?

Well, if we want to be compatible with the older version of buildctl, it seems I must build the parser for resolving the output of buildctl prune. 🤔

Or maybe using the BuildKit go API would be the better way?

PTAL @junnplus @AkihiroSuda

STRRL avatar Aug 03 '22 12:08 STRRL

The output of the buildctl prune is not soo standard, it would use both \t and white-space as the delimiter:

You can convert \t to whitespace.

junnplus avatar Aug 03 '22 13:08 junnplus

Parse the JSON if the JSON output is available, otherwise we can just print the bare output from buildctl builder prune

AkihiroSuda avatar Aug 03 '22 13:08 AkihiroSuda

Parse the JSON if the JSON output is available, otherwise we can just print the bare output from buildctl builder prune

Honestly, I wish we could be compatible with older versions because most users are using them.

junnplus avatar Aug 03 '22 13:08 junnplus

The output of the buildctl prune is not soo standard, it would use both \t and white-space as the delimiter:

You can convert \t to whitespace.

Parse the JSON if the JSON output is available, otherwise we can just print the bare output from buildctl builder prune

What about using BuildKit Go API? I prefer to use that instead of parsing the text, because go API seems more stable and easy to use. 🤔

STRRL avatar Aug 03 '22 13:08 STRRL

What about using BuildKit Go API? I prefer to use that instead of parsing the text, because go API seems more stable and easy to use. 🤔

SGTM.

junnplus avatar Aug 03 '22 14:08 junnplus

What about using BuildKit Go API? I prefer to use that instead of parsing the text, because go API seems more stable and easy to use. thinking

SGTM.

Hi @junnplus @AkihiroSuda @fahedouch, I took a look at using buildkit go API instead of using buildctl for pruning cache. It seems it would take more changes, but I still think that worth it.

I think I would create a tracking issue about:

  • migrate the existed build prune using buildkit API
  • then finished the work about system prune

What do you think about it?

STRRL avatar Aug 11 '22 08:08 STRRL

Using buildkit API sounds good but fearing it may increase the binary footprint

Cc @ktock

AkihiroSuda avatar Aug 13 '22 16:08 AkihiroSuda

It has been a long time since this PR not active, I would continue the work in another PR with new codebase.

STRRL avatar Sep 07 '22 07:09 STRRL