-
Notifications
You must be signed in to change notification settings - Fork 533
Update KubeFedConfig API fields to be optional #966
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: font The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@@ -80,19 +91,24 @@ const ( | |||
|
|||
type ClusterHealthCheckConfig struct { | |||
// How often to monitor the cluster health (in seconds). | |||
PeriodSeconds int64 `json:"periodSeconds"` |
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.
Not the fault of this PR, but why should time in the health check config be specified as an integer representing seconds but in the leader election config as a duration? This seems inconsistent to me.
cc: @shashidharatd
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.
yes, there is inconsistency. it was thought like if we explicitly put unit in the option/flag name itself there will be no confusion while providing the config. Otherwise user has to explicitly provide something like "10s" to specify 10 seconds. If user misses the "s" it is still a valid configuration (in nanoseconds) which leads to undesired value getting configured.
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.
Fair enough. Why, though, is this important for cluster health check but not leader election? And which is more consistent with user expectations?
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.
Mostly, it is like that because leader election module uses the Duration
type and if we change them to int
we have to convert and pass the parameters https://github.com/kubernetes-sigs/kubefed/blob/master/cmd/controller-manager/app/leaderelection/leaderelection.go#L72
Leader election module is used by multiple components and i think whoever configures them might already be aware of such an issue :) Now we need to make a choice ;)
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.
If leader election configuration uses duration across components, is there a reason we shouldn't be consistent and also use duration for leader election? And if we use duration for that, why wouldn't we also use duration for the health check 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.
I'm +1 on using duration and removing the unit from the name. I'm less clear on why we'd need to validate that the value was in seconds, is that a CRD thing? Whatever duration is provided could be converted to seconds.
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.
It's not a CRD thing. It's more of a granularity thing. I figured the reason for requiring seconds is to allow a sane amount of interval delay granularity between cluster health checks as anything less than 1 second may not be reasonable.
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 think it's entirely dependent on context. Maybe partial seconds (e.g. 1.5) would be useful in some circumstances? I think setting sane defaults and documenting how and why to change those defaults is a reasonable alternative to strict validation.
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 have no issues with being less opinionated about the level of granularity we allow. We can always enforce a certain level in validation. I think this change should be done in a follow-up PR though since this PR focuses on optional fields.
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.
Please file an issue in the milestone that tracks the transition to use duration for all time fields.
/lgtm |
@font It looks like merging this broke master due to linting errors:
I'm very much confused as to how CI managed to pass for this PR. |
Lint errors are addressed in #973 |
For fields we plan to provide a default such that we won't require the user to specify them, we need to make them optional in order to pass
kubectl
client side validation. CRD client side validation will be enabled by default in k8s v1.15. See https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#publish-validation-schema-in-openapi-v2 for more details.Additionally, optional fields are made pointers. This is to distinguish the user not specifying a value (since it's not required), from the user specifying an invalid value of
0
(for Duration and time) or""
for the empty string (should produce a validation error). It also makes serialized objects cleaner.