Skip to content

⚠️ 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

Merged
merged 7 commits into from
Jul 22, 2025

Conversation

sbueringer
Copy link
Member

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

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 18, 2025
@k8s-ci-robot k8s-ci-robot requested review from elmiko and sivchari July 18, 2025 10:17
@k8s-ci-robot k8s-ci-robot added do-not-merge/needs-area PR is missing an area label size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 18, 2025
@sbueringer sbueringer force-pushed the pr-field-reshuffling branch from 16d7870 to a7f8d81 Compare July 18, 2025 10:20
@sbueringer sbueringer added area/clusterclass Issues or PRs related to clusterclass area/machinehealthcheck Issues or PRs related to machinehealthchecks area/cluster Issues or PRs related to clusters labels Jul 18, 2025
@k8s-ci-robot k8s-ci-robot removed do-not-merge/needs-area PR is missing an area label labels Jul 18, 2025

// MachineHealthCheckRemediationTriggerIf configures if remediations are triggered.
// +kubebuilder:validation:MinProperties=1
type MachineHealthCheckRemediationTriggerIf struct {
Copy link
Member Author

@sbueringer sbueringer Jul 18, 2025

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 :)

Copy link
Member

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

Copy link
Member Author

@sbueringer sbueringer Jul 18, 2025

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.

Copy link
Member

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.

Copy link
Contributor

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.

@sbueringer sbueringer changed the title [WIP] ⚠️ Restructure MHC fields in MHC, Cluster and ClusterClass CRDs ⚠️ Restructure MHC fields in MHC, Cluster and ClusterClass CRDs Jul 18, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 18, 2025
@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-main-gke

@sbueringer
Copy link
Member Author

/hold
Will push another commit for docs

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 18, 2025
@sbueringer
Copy link
Member Author

/assign @JoelSpeed @fabriziopandini


// MachineHealthCheckRemediationTriggerIf configures if remediations are triggered.
// +kubebuilder:validation:MinProperties=1
type MachineHealthCheckRemediationTriggerIf struct {
Copy link
Member

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

@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-main-gke

// triggerIf configures if remediations are triggered.
// If this field is not set, remediations are always triggered.
// +optional
TriggerIf MachineHealthCheckRemediationTriggerIf `json:"triggerIf,omitempty,omitzero"`
Copy link
Member

@enxebre enxebre Jul 21, 2025

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?

Copy link
Member

@enxebre enxebre Jul 21, 2025

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?

Copy link
Member Author

@sbueringer sbueringer Jul 21, 2025

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)

Copy link
Contributor

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

Copy link
Member

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?

Copy link
Member Author

@sbueringer sbueringer Jul 21, 2025

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

@sbueringer sbueringer force-pushed the pr-field-reshuffling branch from 1644530 to e4ed962 Compare July 21, 2025 11:56
@sbueringer
Copy link
Member Author

@fabriziopandini @JoelSpeed @enxebre PTAL, thx! :)

@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-main-gke

@sbueringer sbueringer added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Jul 21, 2025
@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-main-gke

@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-main-gke

@k8s-ci-robot
Copy link
Contributor

@sbueringer: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-apidiff-main c81ae92 link false /test pull-cluster-api-apidiff-main

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.

@fabriziopandini
Copy link
Member

Great work
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 22, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: fde147487d6305cee130dcf4e21c0ee9a9d5ec6a

@sbueringer
Copy link
Member Author

/hold cancel
Doc commit was pushed a while back

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 22, 2025
@fabriziopandini
Copy link
Member

(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

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 22, 2025
@k8s-ci-robot k8s-ci-robot merged commit f3a9726 into kubernetes-sigs:main Jul 22, 2025
19 of 20 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.11 milestone Jul 22, 2025
@sbueringer sbueringer deleted the pr-field-reshuffling branch July 22, 2025 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/cluster Issues or PRs related to clusters area/clusterclass Issues or PRs related to clusterclass area/machinehealthcheck Issues or PRs related to machinehealthchecks cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants