-
Notifications
You must be signed in to change notification settings - Fork 18.7k
builder: add prune options to the API #37651
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
Conversation
api/types/types.go
Outdated
type BuildCachePruneOptions struct { | ||
All bool | ||
KeepDuration time.Duration | ||
KeepStorage float64 // in MB |
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.
@AkihiroSuda @vdemeester I'm not sure if I want KeepStorage
here or KeepBytes
like in Buildkit API, though on the CLIs it's --keep-storage
. Let me know what you think.
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.
either is fine, but I think the type should be int64
in bytes
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.
@tiborvass same as @AkihiroSuda 😝, KeepStorage
is fine 😉
|
||
opts := types.BuildCachePruneOptions{ | ||
All: httputils.BoolValue(r, "all"), | ||
KeepDuration: time.Duration(kd), |
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.
kd * time.Second
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.
or errors.Wrap(err, "keep-duration expects an integer number in milliseconds")
api/types/types.go
Outdated
// BuildCachePruneOptions hold parameters to prune the build cache | ||
type BuildCachePruneOptions struct { | ||
All bool | ||
KeepDuration time.Duration |
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.
Gonna summarize a conversation that @tiborvass and I had offline. If we've understood the criteria for pruning correctly a given cache layer will be kept if it meets the KeepDuration
criterion and meets the KeepStorage
criterion. In other words keep rules are conjunctive and by De Morgan's law, purge rules are disjunctive 😜
If that's the case I would rename KeepDuration
to KeepMaxAge
. Duration implies that the cached item will be kept around for that amount of time, whereas max age implies it will be kept for a maximum of that amount of time given all other criteria are also met.
ac354f6
to
dc9b62f
Compare
@tiborvass Hmm...janky no likey:
|
} | ||
|
||
opts := types.BuildCachePruneOptions{ | ||
All: httputils.BoolValue(r, "all"), |
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.
For my clarification:
Isnt all
mutually exclusive with the Keep* options?
Also, what happens when KeepDuration
is met but KeepStorage
isnt or vice versa?
a39e158
to
88f575d
Compare
Only one failure on z known to be flakey:
|
SGTM wrt getting apis for pruning things that are built |
@anusha-ragunathan There are different type of caches in buildkit: for regular cache, frontend images, internal images. By default only regular cache is pruned, but if you specify |
Talked with @tiborvass about this. The conclusion was to move the maxage to a filter, leave everything else as is as other fields are not really filters. For the gc, it is a list of these same options that just apply automatically and if the user wants to override they can do it with the config file initially. |
88f575d
to
a60ee5d
Compare
a60ee5d
to
16f3ae0
Compare
3af5dbc
to
5340314
Compare
@tonistiigi @AkihiroSuda @vdemeester So this round of changes include:
|
Failures are unrelated. |
} | ||
ks, err := strconv.Atoi(r.FormValue("keep-storage")) | ||
if err != nil { | ||
return errors.Wrap(err, "keep-storage is in bytes and expects an integer") |
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.
nit: print values on parse errors
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.
Addressed.
Signed-off-by: Tibor Vass <tibor@docker.com>
Signed-off-by: Tibor Vass <tibor@docker.com>
5340314
to
efdaf61
Compare
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com> Signed-off-by: Tibor Vass <tibor@docker.com>
efdaf61
to
354c241
Compare
@tonistiigi I pushed your fix for |
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.
LGTM 🐯
Looks like we forgot to update the API changelog document in this PR |
Signed-off-by: Tibor Vass tibor@docker.com