-
Notifications
You must be signed in to change notification settings - Fork 1.4k
⚠️ Restructure MHC fields in MHC, Cluster and ClusterClass CRDs #12504
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
⚠️ Restructure MHC fields in MHC, Cluster and ClusterClass CRDs #12504
Conversation
16d7870
to
a7f8d81
Compare
|
||
// MachineHealthCheckRemediationTriggerIf configures if remediations are triggered. | ||
// +kubebuilder:validation:MinProperties=1 | ||
type MachineHealthCheckRemediationTriggerIf struct { |
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.
MHC now looks like this
spec:
checks:
nodeStartupTimeoutSeconds: 0
unhealthyNodeConditions: []
remediation:
templateRef: {}
triggerIf:
unhealthyLessThanOrEqualTo: 100%
unhealthyInRange: "[1-4]"
Open point from Joel:
remediation.triggerIf, not sure if other names were considered, but could also be triggerWhen, or triggerIfNodes/triggerWhenNodes - I got thinking about whether nodes should be in the context, since it's not in the child fields?
I would prefer triggerIf
, we have things like enabledIf
in our APIs already.
Regarding adding Node, I think if we add it we should consider adding it to the child fields, like we already have below checks. On the other side here "unhealthy" applies more to Machines or actually Machines and Nodes? So probably keeping the current names would be better
cc @fabriziopandini @JoelSpeed Let's finalize this :)
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 leaning toward triggerWhen, it seems more precise in this case
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.
First google result, not sure if true
We use "when" when we know something is going to happen, there's 100% certainty here. This is a key point, it's going to happen.
"If," on the other hand, we use "if" if there's only a chance something is going to happen. There's only a chance, it is not determined, it is not something that has been decided.
Another one
If is used to discuss conditional or uncertain events, indicating the possibility that an event may or may not happen. On the other hand, when is used when you're certain that an event will happen, and it pertains to timing rather than conditionality.
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.
On the other side here "unhealthy" applies more to Machines or actually Machines and Nodes? So probably keeping the current names would be better
I agree with this.
"If," on the other hand, we use "if" if there's only a chance something is going to happen. There's only a chance, it is not determined, it is not something that has been decided.
I see it like this.
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 happy to leave as is, it seems that's preferred by Stefan and Alberto at least, and the enabledIf
consistency is positive.
/test pull-cluster-api-e2e-main-gke |
/hold |
/assign @JoelSpeed @fabriziopandini |
|
||
// MachineHealthCheckRemediationTriggerIf configures if remediations are triggered. | ||
// +kubebuilder:validation:MinProperties=1 | ||
type MachineHealthCheckRemediationTriggerIf struct { |
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 leaning toward triggerWhen, it seems more precise in this case
/test pull-cluster-api-e2e-main-gke |
Signed-off-by: Stefan Büringer buringerst@vmware.com
// triggerIf configures if remediations are triggered. | ||
// If this field is not set, remediations are always triggered. | ||
// +optional | ||
TriggerIf MachineHealthCheckRemediationTriggerIf `json:"triggerIf,omitempty,omitzero"` |
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.
as an optional struct, shouldn't this be a pointer?
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.
same question for Remediation, checks... or did we agree on something else?
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.
Why should an optional struct be a pointer?
From an API best practices perspective pointer + omitempty or non-pointer + omitempty,omitzero works
(we did this for many fields in the last few weeks, see e.g.: #12482, #12489)
(cc @JoelSpeed)
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.
From an API best practices perspective pointer + omitempty or non-pointer + omitempty,omitzero works
This is quite a new thing, with Go 1.24 we can now use omitzero
. So, as long as there is no valid use case for a {}
meaning something different than omitted, the correct thing now is to be not a pointer, and have omitzero
. This should make coding simpler for folks over time as we will have far fewer dereference points for structs
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.
ack. Does this then set a hard dep on clients needing to be on go 1.24?
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. But we already have that because we rely on controller-runtime (>=v0.21) and k8.io (>=v0.33) versions that require Go 1.24
1644530
to
e4ed962
Compare
@fabriziopandini @JoelSpeed @enxebre PTAL, thx! :) |
/test pull-cluster-api-e2e-main-gke |
/test pull-cluster-api-e2e-main-gke |
/test pull-cluster-api-e2e-main-gke |
@sbueringer: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Great work |
LGTM label has been added. Git tree hash: fde147487d6305cee130dcf4e21c0ee9a9d5ec6a
|
/hold cancel |
(after a quick sync with Stefan) /approve So we can keep working on other changes in #12497 before getting to near to the code freeze. If there will be some late feedback, we will address then in a follow up |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: fabriziopandini 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 |
Signed-off-by: Stefan Büringer buringerst@vmware.com
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Part of #12497