Repository navigation
config: fix a default GC policy filter never matching any record - #6856
Merged
Merged
Conversation
ZRHann
force-pushed
the
fix-default-gc-policy-filter
branch
from
June 10, 2026 12:29
3a87c33 to
67340aa
Compare
The first default GC policy is meant to prune the most easily
reproducible cache (local sources, cache mounts, git checkouts) once it
exceeds 512MB and has not been used for 48h. Its filter was written as a
single comma-joined string:
"type==source.local,type==exec.cachemount,type==source.git.checkout"
Each element of the Filters slice is passed to
containerd/filters.ParseAll, where commas within one string are ANDed
together. A record only ever has a single type, so the AND can never be
satisfied: this policy matched nothing and was effectively a no-op.
Split the filter into separate slice elements so they are ORed, matching
the documented intent and the array form already used in user
buildkitd.toml configs.
Signed-off-by: ZRHann <zrhann@foxmail.com>
ZRHann
force-pushed
the
fix-default-gc-policy-filter
branch
from
June 10, 2026 13:34
67340aa to
b69e279
Compare
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
tonistiigi
approved these changes
Jun 10, 2026
Contributor
Author
|
@tonistiigi thanks for the review! Do you think we should drop the test, though? It only checks the specific types the default happens to use, so it's really just a change detector. I couldn't think of a better, more general way to test this. |
Member
|
@ZRHann I think it is fine atm. This filters API is so confusing that it is better to force updating the test if something changes to make sure nothing was missed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The first default GC policy is meant to prune the most easily reproducible cache (local sources, cache mounts, git checkouts) once the build cache exceeds 512MB and the data has been unused for 48h.
Its filter was written as a single comma-joined string:
Each element of
GCPolicy.Filtersis passed tocontainerd/filters.ParseAll. Selectors separated by commas within a single string are ANDed together (ParseAllonly ORs across separate slice elements). Since a record only ever has a singletype, the expressiontype==source.local AND type==exec.cachemount AND type==source.git.checkoutcan never be satisfied — so this policy matched nothing and was effectively a no-op.Fix
Split the filter into separate slice elements so they are ORed, matching the documented intent. This is also the form that already works when the array is written in
buildkitd.toml:A regression test verifies the first default policy's filter matches the three reproducible record types and not regular build cache.