-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
⚠️ MachineHealthCheck Spec.Selector field cannot be empty #3032
⚠️ MachineHealthCheck Spec.Selector field cannot be empty #3032
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vincepri 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 |
/milestone v0.3.6 |
cc @sedefsavas for the e2e tests |
Marked as a |
/lgtm |
LGTM too, one suggestion might be to add a test case with an empty selector so that we can see an empty selector makes the validation fail? Should be pretty simple to add to |
if err != nil { | ||
allErrs = append( | ||
allErrs, | ||
field.Invalid(field.NewPath("spec", "selector"), m.Spec.Selector, err.Error()), | ||
) | ||
} | ||
|
||
// Validate that the selector isn't empty. |
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.
nit: Since empty label selector is actually a valid semantic https://github.com/kubernetes/kubernetes/blob/665e76d97623447d13bb3b33b68591a985b49c9d/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go#L1041
It'd be helpful to add the reasoning behind this in the commit description (git commit -m"" -m"This is to prevent users from accidentally..."
).
1eec34c
to
721bda3
Compare
/hold cancel Added the test case, for the text of the error if you have any suggestion that'd be great — otherwise I'd leave it like this for now and improve it later |
I think the error is fine for now. There's still an outstanding comment from @enxebre that should be fixed before merge |
@JoelSpeed that's what I meant by error :) — I'm not sure what to write in there without going into much details and while trying to be consistent with the other errors |
These changes LGTM. |
I think @enxebre just wanted to see some motivation in the commit message itself rather than in the code. The error message itself that is shown to users is separate as far as I can tell? It's not immediately obvious looking at the commit history why this change was made I think is the point |
An empty selector is usually a valid selector that matches all objects; in Cluster API usually we disallow its use given the scope of our project is to manage the lifecycle of Kubernetes clusters and having an "everything" selector could lead users into errors. For MachineHealthCheck in particular, an empty selector would match all the machines in a given cluster; given that we don't want to have overlapping health checks, it makes sense to disable it and make it opt-in. Signed-off-by: Vince Prignano <[email protected]>
721bda3
to
7ad907d
Compare
@JoelSpeed fixed, ptal |
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
Thanks for updating @vincepri , description is ++
/test pull-cluster-api-make |
Signed-off-by: Vince Prignano [email protected]
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):Fixes #3006