-
Notifications
You must be signed in to change notification settings - Fork 14
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
Use optional fields for ClusterConfig #256
Merged
Merged
Conversation
This file contains 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
bschimke95
approved these changes
Mar 18, 2024
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.
Great work as always @neoaggelos
Just a few nits.
Waiting for #279 to rebase |
- avoid unnecessary setup - test kubelet restarts
bschimke95
approved these changes
Apr 3, 2024
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
|
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
Update all cluster configurations to use
*<type>
fields, such that they can be set to empty values. The changes are extensive but are mostly to introduce structure to the code, and ensure that all checks happen in the right placeNotes
Changes
apiv1.UserFacingClusterConfig
does not have nil structs, all individual fields can benil
instead.Getter()
functions for all fields, to avoid having to check for pointers all around the code. To facilitate this, all zero values and nil values of fields should behave identically.types.ClusterConfig
rework, same as above. All fields can benil
, and all structs are never nil.types
packagetypes
packagedatabase.SetClusterConfig()
now also returns the merged cluster config, simplifying code in the caller sites.json
for storing the cluster configuration.types.ClusterConfig.SetDefaults()
sets all fields such that they are not nil.Previous issues
Validating the merged cluster configuration happened in two steps, in
types.MergeClusterConfig
and then inapi.validateConfig
. This is now handled properly intypes.MergeClusterConfig
instead. Extensive tests have been added to validate the expected behavioursDefault values for the cluster config were split between
(*types.ClusterConfig).SetDefaults()
andutils.GetUserFacingClusterConfig
, making it hard to track around the code if a particular value is nil, or if the user will be presented with slightly misleading configs.Converting to and from userfacing config has been moved to the
types
package, it does not belong inutils
, especially not coupled with retrieving the cluster config from the databaseIt was impossible to "unset" configurations after they had been configured (e.g. reset the
load-balancer.cidrs
) field. We now use optional fields for everything (*type
). We now considernil
values instead ofzero
values as "don't update". Further, we ensure that for each field the zero and the nil value behave in the same way, such that we can have straightforwardGet$Field()
and simplify the code.This now works: