Skip to content
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

🐛 Change MachineHealthCheck.spec.unhealthyConditions to optional #9774

Merged
merged 12 commits into from
Apr 5, 2024

Conversation

mcbenjemaa
Copy link
Member

What this PR does / why we need it:

The MHC API doesn't allow creating a health check for a missing node only,
it requires you to create fake conditions.

This PR, make the spec.unhealthyConditions to allow creating MHC for missing nodes.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #9762

/area machinehealthcheck

@k8s-ci-robot k8s-ci-robot added area/machinehealthcheck Issues or PRs related to machinehealthchecks cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 27, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @mcbenjemaa. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

@sbueringer
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 27, 2023
@mcbenjemaa
Copy link
Member Author

/retest

@enxebre
Copy link
Member

enxebre commented Nov 28, 2023

Can we please include a test case for a healthCheckTarget with a MHC with empty conditions in TestHealthCheckTargets?
Can we please also include a test case for empty conditions within TestMachineHealthCheck_Reconcile in addition to the existing "when a Machine's Node has gone away"

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 3, 2023
@enxebre
Copy link
Member

enxebre commented Dec 4, 2023

Thanks! lgtm after addressing https://github.com/kubernetes-sigs/cluster-api/pull/9774/files#r1413546275 and squashing commits.

@sbueringer
Copy link
Member

/test pull-cluster-api-test-main

@sbueringer
Copy link
Member

Looks like you have to run make generate-go-openapi. (or make the change here manually: https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cluster-api/9774/pull-cluster-api-verify-main/1732354796511301632)

@mcbenjemaa
Copy link
Member Author

Looks like you have to run make generate-go-openapi. (or make the change here manually: https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cluster-api/9774/pull-cluster-api-verify-main/1732354796511301632)

Looks like make generate-go-openapi does nothing?

@sbueringer
Copy link
Member

Looks like you have to run make generate-go-openapi. (or make the change here manually: prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cluster-api/9774/pull-cluster-api-verify-main/1732354796511301632)

Looks like make generate-go-openapi does nothing?

We had an issue in the past with running this when the repository was outside of the "GOPATH" location: #6526

But as far as I know we got this resolved.

On my Ubuntu Machine I end up with the following diff after running this target:

-                               Required: []string{"clusterName", "selector", "unhealthyConditions"},
+                               Required: []string{"clusterName", "selector"},

(same as in Prow)

@mcbenjemaa
Copy link
Member Author

@sbueringer I'm on Macos, I tried to generate in the GOPATH but still not working.

this what i got:

GOBIN=/Users/mbenjemaa/workspace/go/src/github.com/mcbenjemaa/cluster-api/hack/tools/bin ./scripts/go_install.sh k8s.io/kube-openapi/cmd/openapi-gen openapi-gen 5e7f5fd
** Generating openapi schema for types in ./api/v1beta1 **
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,ClusterClassPatch,Definitions
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,ClusterClassSpec,Patches
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,ClusterClassSpec,Variables
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,ClusterClassStatus,Variables
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,ClusterClassStatusVariable,Definitions
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,JSONSchemaProps,Enum
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,JSONSchemaProps,Required
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,MachineDeploymentVariables,Overrides
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,MachineHealthCheckClass,UnhealthyConditions
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,MachineHealthCheckSpec,UnhealthyConditions
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,MachineHealthCheckStatus,Targets
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,MachinePoolClass,FailureDomains
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,MachinePoolTopology,FailureDomains
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,MachinePoolVariables,Overrides
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,NetworkRanges,CIDRBlocks
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,PatchDefinition,JSONPatches
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,PatchSelectorMatchMachineDeploymentClass,Names
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,PatchSelectorMatchMachinePoolClass,Names
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,Topology,Variables
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,WorkersClass,MachineDeployments
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,WorkersClass,MachinePools
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,WorkersTopology,MachineDeployments
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,WorkersTopology,MachinePools
API rule violation: names_match,sigs.k8s.io/cluster-api/api/v1beta1,JSONSchemaProps,XPreserveUnknownFields
** Generating openapi schema for types in ./exp/runtime/hooks/api/v1alpha1 **
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1,DiscoverVariablesResponse,Variables
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1,GeneratePatchesRequest,Items
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1,GeneratePatchesRequest,Variables
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1,GeneratePatchesRequestItem,Variables
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1,GeneratePatchesResponse,Items
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1,GeneratePatchesResponseItem,Patch
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1,ValidateTopologyRequest,Items
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1,ValidateTopologyRequest,Variables
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1,ValidateTopologyRequestItem,Variables

@sbueringer
Copy link
Member

$ make generate-go-openapi
GOBIN=/Users/buringerst/code/src/sigs.k8s.io/cluster-api/hack/tools/bin ./scripts/go_install.sh k8s.io/kube-openapi/cmd/openapi-gen openapi-gen 5e7f5fd
go: downloading k8s.io/kube-openapi v0.0.0-20220413171646-5e7f5fdc6da6
go: downloading github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e
make[1]: *** No rule to make target `clean-generated-openapi-definitions'.  Stop.
** Generating openapi schema for types in ./api/v1beta1 **
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,ClusterClassPatch,Definitions
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,ClusterClassSpec,Patches
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,ClusterClassSpec,Variables
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,ClusterClassStatus,Variables
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,ClusterClassStatusVariable,Definitions
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,JSONSchemaProps,Enum
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,JSONSchemaProps,Required
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,MachineDeploymentVariables,Overrides
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,MachineHealthCheckClass,UnhealthyConditions
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,MachineHealthCheckSpec,UnhealthyConditions
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,MachineHealthCheckStatus,Targets
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,MachinePoolClass,FailureDomains
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,MachinePoolTopology,FailureDomains
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,MachinePoolVariables,Overrides
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,NetworkRanges,CIDRBlocks
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,PatchDefinition,JSONPatches
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,PatchSelectorMatchMachineDeploymentClass,Names
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,PatchSelectorMatchMachinePoolClass,Names
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,Topology,Variables
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,WorkersClass,MachineDeployments
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,WorkersClass,MachinePools
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,WorkersTopology,MachineDeployments
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/api/v1beta1,WorkersTopology,MachinePools
API rule violation: names_match,sigs.k8s.io/cluster-api/api/v1beta1,JSONSchemaProps,XPreserveUnknownFields
make[1]: *** No rule to make target `clean-generated-openapi-definitions'.  Stop.
** Generating openapi schema for types in ./exp/runtime/hooks/api/v1alpha1 **
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1,DiscoverVariablesResponse,Variables
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1,GeneratePatchesRequest,Items
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1,GeneratePatchesRequest,Variables
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1,GeneratePatchesRequestItem,Variables
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1,GeneratePatchesResponse,Items
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1,GeneratePatchesResponseItem,Patch
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1,ValidateTopologyRequest,Items
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1,ValidateTopologyRequest,Variables
API rule violation: list_type_missing,sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1,ValidateTopologyRequestItem,Variables

$ pwd
/Users/buringerst/code/src/sigs.k8s.io/cluster-api

$ echo $GOPATH
/Users/buringerst/code

$ git diff
diff --git a/api/v1beta1/zz_generated.openapi.go b/api/v1beta1/zz_generated.openapi.go
index 073de884b..fe9c4584d 100644
--- a/api/v1beta1/zz_generated.openapi.go
+++ b/api/v1beta1/zz_generated.openapi.go
@@ -2282,7 +2282,7 @@ func schema_sigsk8sio_cluster_api_api_v1beta1_MachineHealthCheckSpec(ref common.
                                                },
                                        },
                                },
-                               Required: []string{"clusterName", "selector", "unhealthyConditions"},
+                               Required: []string{"clusterName", "selector"},
                        },
                },
                Dependencies: []string{

This time on Apple M2

@mcbenjemaa
Copy link
Member Author

ready

@sbueringer
Copy link
Member

I would take another look once the open findings are addressed

@mcbenjemaa
Copy link
Member Author

@fabriziopandini will you take another look here

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 16, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 20, 2024
Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two small typo nits (which already did exist before) :-)

As of that I'm lgtm for this change 👍

Thanks for working on this! 🎉

internal/webhooks/machinehealthcheck_test.go Outdated Show resolved Hide resolved
internal/webhooks/machinehealthcheck_test.go Outdated Show resolved Hide resolved
@chrischdi
Copy link
Member

/assign @sbueringer

@sbueringer sbueringer added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Apr 5, 2024
@sbueringer
Copy link
Member

@mcbenjemaa Sorry for the delay, and thank you very much for seeing this through and the patience!!!

/lgtm
/approve

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

LGTM label has been added.

Git tree hash: 530ba36bee19420c227bb63b5ae2dda53307498a

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

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 Apr 5, 2024
@k8s-ci-robot k8s-ci-robot merged commit b7b53ca into kubernetes-sigs:main Apr 5, 2024
22 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.8 milestone Apr 5, 2024
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/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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 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.

Consider dropping MachineHealthCheck conditions validations
6 participants