The Wayback Machine - https://web.archive.org/web/20251014201934/https://github.com/moby/moby/pull/49137
Skip to content

Conversation

thaJeztah
Copy link
Member

(cherry picked from commit b08ff81)

- What I did

Builder GC policies without a keepStorage option set should fall back to using the defaultKeepStorage value. But currently, the policy's keepStorage is parsed unconditionally, meaning that if it's unset, an error occurs:

could not get builder GC policy: invalid size: ''

The only way to get a policy to use defaultKeepStorage limit for GC would be to set it to "0".

This patch is to make sure policy keepStorage is conditionally parsed, if set, otherwise the defaultKeepStorage is used.

I also modified related error messages:

could not get builder GC policy: failed to parse defaultKeepStorage: invalid size: 'foo'
could not get builder GC policy: failed to parse keepStorage: invalid size: 'bar'

- How I did it

- How to verify it

Tested manually;

{
        "builder": {
                "gc": {
                        "enabled": true,
                        "defaultKeepStorage": "10GB",
                        "policy": [ { "filter": ["unused-for=2200h"] } ] 
                }
        }
}
$ docker buildx inspect
...
GC Policy rule#0:
 All:            false
 Filters:        
 Keep Duration:  2200h0m0.5074347s
 Reserved Space: 10GiB

- Description for the changelog

- Builder GC policies without a `keepStorage` value now inherit the `defaultKeepStorage` limit as intended.

- A picture of a cute animal (not mandatory but encouraged)

…GC policy

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
(cherry picked from commit b08ff81)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah added this to the 27.5.0 milestone Dec 19, 2024
@thaJeztah thaJeztah self-assigned this Dec 19, 2024
@thaJeztah thaJeztah merged commit 09b6837 into moby:27.x Dec 19, 2024
147 checks passed
@thaJeztah thaJeztah deleted the 27.x_backport_builder-gcpolicy-empty-keepbytes branch December 19, 2024 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants