-
Notifications
You must be signed in to change notification settings - Fork 18.8k
config: set buildkit gc enabled to default to true #49899
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
6c54381
to
c2eaed4
Compare
c2eaed4
to
98b977a
Compare
|
||
func (x *BuilderGCConfig) IsEnabled() bool { | ||
return x.Enabled == nil || *x.Enabled | ||
} | ||
|
||
func (x *BuilderGCConfig) UnmarshalJSON(data []byte) error { | ||
var xx struct { | ||
Enabled bool `json:",omitempty"` |
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 was even considering if we had to modify BuilderGCConfig. Enabled
to be a pointer, or if we'd only need to modify this temporary struct (unmarshal to xx
and if it's nil, then we set the default to true, which we already do below), but that would require New()
to set the default (for cases where the UnmarshalJSON
is not called, and looks like we'd have to patch other places to start with New()
(default config) instead of starting with an empty config.
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.
Modifying the temporary struct doesn't work because UnmarshalJSON
only gets called if there's a gc section. So doing the change in the temporary struct works for this:
"builder": {"gc": {}}
But it doesn't work when "gc"
is missing or if the entire configuration is missing. At the same time, doing it this way ensures that "enabled": null
isn't accidentally an acceptable value. If the temporary struct has a pointer, then it would be ok for someone to set null
as the value. If we set Enabled
to true before running unmarshal then it will be set to true if the attribute isn't present otherwise it'll be overridden and null
will cause it to error.
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.
Yeah, I came to that conclusion as well; I had a bit of a brain-fart and thought it would be called unconditionally, but that's that didn't really make sense;
for cases where the UnmarshalJSON is not called
This will use the default settings for buildkit gc unless explicitly disabled by setting `enabled: false` in the gc configuration. Signed-off-by: Jonathan A. Sternberg <[email protected]>
98b977a
to
a79d081
Compare
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
This will use the default settings for buildkit gc unless explicitly
disabled by setting
enabled: false
in the gc configuration.Fixes #49826.