Repository navigation
api/types/build: move build cache prune options from api to client #50772
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -33,6 +33,7 @@ import ( | |||
| "github.com/moby/moby/v2/daemon/libnetwork" | ||||
| "github.com/moby/moby/v2/daemon/pkg/opts" | ||||
| "github.com/moby/moby/v2/daemon/server/backend" | ||||
| "github.com/moby/moby/v2/daemon/server/buildbackend" | ||||
| "github.com/moby/moby/v2/errdefs" | ||||
| "github.com/moby/sys/user" | ||||
| "github.com/pkg/errors" | ||||
|
|
@@ -187,7 +188,7 @@ func (b *Builder) DiskUsage(ctx context.Context) ([]*build.CacheRecord, error) { | |||
| } | ||||
|
|
||||
| // Prune clears all reclaimable build cache. | ||||
| func (b *Builder) Prune(ctx context.Context, opts build.CachePruneOptions) (int64, []string, error) { | ||||
| func (b *Builder) Prune(ctx context.Context, opts buildbackend.CachePruneOptions) (int64, []string, error) { | ||||
| ch := make(chan *controlapi.UsageRecord) | ||||
|
|
||||
| eg, ctx := errgroup.WithContext(ctx) | ||||
|
|
@@ -641,7 +642,7 @@ func toBuildkitUlimits(inp []*container.Ulimit) (string, error) { | |||
| return strings.Join(ulimits, ","), nil | ||||
| } | ||||
|
|
||||
| func toBuildkitPruneInfo(opts build.CachePruneOptions) (client.PruneInfo, error) { | ||||
| func toBuildkitPruneInfo(opts buildbackend.CachePruneOptions) (client.PruneInfo, error) { | ||||
| var until time.Duration | ||||
| untilValues := opts.Filters.Get("until") // canonical | ||||
| unusedForValues := opts.Filters.Get("unused-for") // deprecated synonym for "until" filter | ||||
|
|
@@ -696,10 +697,6 @@ func toBuildkitPruneInfo(opts build.CachePruneOptions) (client.PruneInfo, error) | |||
| } | ||||
| } | ||||
|
|
||||
| if opts.ReservedSpace == 0 && opts.KeepStorage != 0 { | ||||
| opts.ReservedSpace = opts.KeepStorage | ||||
| } | ||||
|
Comment on lines
-699
to
-701
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to account for old clients setting that option? @crazy-max if you have time to look along (also see my comment further up, which made my head spin a little 😅)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems that is covered in the router code. Ref:
From what I see
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah; derp; missed that one. It was late 😂 |
||||
|
|
||||
| return client.PruneInfo{ | ||||
| All: opts.All, | ||||
| KeepDuration: until, | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package buildbackend | ||
|
|
||
| import "github.com/moby/moby/api/types/filters" | ||
|
|
||
| type CachePruneOptions struct { | ||
| All bool | ||
| ReservedSpace int64 | ||
| MaxUsedSpace int64 | ||
| MinFreeSpace int64 | ||
| Filters filters.Args | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for these version-specific constraints we don't have to keep separate tracking tickets; the version-gate itself is an implicit "remove once we drop this version".
Definitely fine for a follow-up, or when we rewrite these to functional args; for the functional args, perhaps we can even use our own struct tags on options for checking the API version 🤔