-
Notifications
You must be signed in to change notification settings - Fork 490
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
Add validation for Kubernetes object name fields and ProtocolType #871
Add validation for Kubernetes object name fields and ProtocolType #871
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: youngnick 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 |
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.
Sorry if my regex knowledge is wrong here but I think this breaks the examples for ExternalService types where we have things like google.com?
Or I guess that is fine since there is no /. But a UDS would be broken. Or a GCS bucket. Object references need not be Kubernetes objects and therefore shouldn't be subject to validation in my opinion
I have assumed that the ObjectReferences here must be to Kubernetes objects. I can see that it would be handy to be able to fudge a direct reference to a non-Kubernetes thing, but I guess I had assumed that in that case there would be some Kubernetes object to represent the external object first. If we are not going to require that references are to Kubernetes objects, then we should record that fact alongside the all the object name references. |
+1 to both points by Nick. |
Dang, I should have talked about this in the meeting today. I'll start a Slack thread so we can go async. |
Yeh, I had the same assumption. |
Okay, I'll leave this until we can come to some agreement about the project's stance on if the references must be to Kubernetes objects only, https://kubernetes.slack.com/archives/CR0H13KGA/p1632187311091400 is the Slack thread to discuss. |
The Slack thread referenced by @youngnick above has gotten fairly long. Here's a summary of what I think the current state is for each of the two relevant questions. 1. Should we validate Name in ObjectRefs? 2. Should we be open to using ObjectRefs to reference non-k8s objects?
Although I'm personally open to the idea of referencing virtual or non-k8s resources, I don't feel as strongly about it. It seems mostly reasonable to start without this concept with the idea that we can add it later if necessary with a simple addition to docs and no change in validation. |
Okay, finishing up for the day but tomorrow after the meeting I will update this and remove the object name validation, and clarify that objects must be Kubernetes resources. |
c5b7b60
to
b225d22
Compare
In the latest commit, I:
|
🤦 |
9a0ef43
to
00c7975
Compare
Well, the system works, turned out there were a couple of regex problems, which the tests picked up! Fixed now. |
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.
Thanks for the work on this @youngnick! I personally don't think we need regex validation for ObjectName, but also would be fine if it was added. I'm leaving a hold on here in case you want to add something based on the sig-api-machinery thread.
/lgtm
/hold
// | ||
// +kubebuilder:validation:MinLength=1 | ||
// +kubebuilder:validation:MaxLength=253 | ||
type ObjectName string |
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 followed up with sig-api-machinery and it sounds like there is a minimum set of validation we can provide here. It may be a bit difficult to translate into regex validation though, and others recommended against adding validation here. Although that minimum set of validation does not include a max length, 253 seems like a reasonable value to me based on the most common validation + ensure we don't end up with an unbounded list.
I don't think that doing that level of checking is worthwhile when the apiserver will stop you creating objects with that name anyway; I think it's more important to get the "must refer to an existing type" clauses in. /hold cancel |
Signed-off-by: Nick Young <ynick@vmware.com>
Signed-off-by: Nick Young <ynick@vmware.com>
Signed-off-by: Nick Young <ynick@vmware.com>
00c7975
to
6b2f46d
Compare
Thanks! /lgtm |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This PR ensures that there are no required fields that allow empty values, and that all required fields have consistent validation.
It does this by introducing a new string type alias, ObjectName, for Kubernetes object names, and by ensuring that the Listener ProtocolType has validation.
On the plus side, that was all the required types that could be zero I could find. The Port number field already has validation to ensure it's between 1 and 65535.
Which issue(s) this PR fixes:
Fixes #867
Does this PR introduce a user-facing change?: