-
Notifications
You must be signed in to change notification settings - Fork 513
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
feat: make Gateway.Spec.Addresses.Value
optional
#3616
base: main
Are you sure you want to change the base?
feat: make Gateway.Spec.Addresses.Value
optional
#3616
Conversation
Hi @EyalPazz. 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 Once the patch is verified, the new status will be reflected by the 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-sigs/prow repository. |
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.
This needs more specification; changing a field to optional is not a breaking change, but it is a big one that will require code updates from all controllers. If you are proposing this, including how to handle empty values for implementations that support it and do not will be important.
We may also need an extended feature to cover this GatewayAddressEmpty
or something, so that we can slice the conformance tests accordingly.
26365be
to
d39cc82
Compare
@youngnick, this isn't ready for merge yet, i wanted your opinion on injecting a valid |
d39cc82
to
581ba80
Compare
@shaneutt , i'd also appreciate your opinion here, as i saw you wrote the |
That seems reasonable, yes. |
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 taking this on @EyalPazz!
apis/v1/gateway_types.go
Outdated
// +kubebuilder:validation:MinLength=1 | ||
// +kubebuilder:validation:MaxLength=253 | ||
Value string `json:"value"` |
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.
Although the +optional
is a convention, we have two options to make this optional:
A) A pointer to allow for nil/unspecified values
// +kubebuilder:validation:MinLength=1 | |
// +kubebuilder:validation:MaxLength=253 | |
Value string `json:"value"` | |
// +kubebuilder:validation:MinLength=1 | |
// +kubebuilder:validation:MaxLength=253 | |
Value *string `json:"value,omitempty"` |
B) Allow empty string (no need to distinguish between empty string and unspecified here, so this is likely better)
// +kubebuilder:validation:MinLength=1 | |
// +kubebuilder:validation:MaxLength=253 | |
Value string `json:"value"` | |
// +kubebuilder:validation:MaxLength=253 | |
Value string `json:"value,omitempty"` |
Would appreciate some other input on this from others like @youngnick before committing to an approach.
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, I agree that because empty string means the same thing as unspecified, I'm fine with not moving to a pointer, and just allowing this to default to ""
.
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.
what are scenarios where we'll want to use 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.
Good question, I didn't make that very clear.
The pointer is useful when you want to be able to distinguish between unspecified (nil) and empty (""). In our case we don't so a string without a min length is fine but in some cases it is a useful distinction.
gatewayClassName: "{GATEWAY_CLASS_NAME}" | ||
addresses: | ||
# How should we inject a valid type here? | ||
- type: "VALID_ADDRESS_TYPE_PLACEHOLDER" |
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.
This seems like the fundamental challenge of writing a conformance test for this. As far as I know, none of our conformance tests so far require a specific address type. I like your idea of allowing this to be a configurable flag on the test suite and that's probably sufficient as a starting point. It could be useful to expand this in the future to have a separate SupportedFeature
per type though.
|
||
// SupportGatewayAddressEmpty option indicates support for an empty | ||
// spec.addresses.value field | ||
SupportGatewayAddressEmpty FeatureName = "GatewayAddressEmpty" |
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.
This feature name doesn't quite seem right. Maybe useful to describe the address options that will be available after this PR merges:
- Gateway.spec.addresses unspecified - implementation automatically assigns address(es) of whatever type(s) they choose
- Gateway.spec.addresses.value unspecified (new in this PR) - implementation automatically assigns address(es) of the type requested (if possible)
- Gateway.spec.addresses fully specified - implementation automatically assigns address requested (if possible)
So that's a long way of saying that the thing that's new here is the ability to request a type of address without specifying the desired value. So maybe a better name would be GatewayTypedAddressAllocation
although that's awfully verbose. Naming is decidedly not my specialty, but something in that general direction would probably be helpful.
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.
can't a fully specified Gateway.spec.addresses also be considered a TypedAddress
?
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.
How about GatewayAutoAddressAssignment
(as opposed to the existing static assignment)?
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.
can't a fully specified Gateway.spec.addresses also be considered a TypedAddress?
Fair point.
How about GatewayAutoAddressAssignment (as opposed to the existing static assignment)?
Isn't this what happens by default with most/all Gateways when spec.addresses
is empty?
Maybe a generic name like "GatewayAddressByType" would work, but even that doesn't feel quite right. The more I think about this, the more it seems like starting with names per address type like "GatewayIPAddressAllocation" would be the most future proof path here.
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.
The more I think about this, the more it seems like starting with names per address type like "GatewayIPAddressAllocation" would be the most future proof path here.
and then add a feature for each type of each provider?
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.
or have IPAddress | Hostname | Dynamic
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.
and then add a feature for each type of each provider?
Theoretically yes, but I think all existing Gateway API implementations support IP Address, so that's probably a sufficient starting point.
or have IPAddress | Hostname | Dynamic
What would Dynamic mean here? My intention with GatewayIPAddressAllocation
was that it would indicate that a Gateway would provision an IPAddress if requested in spec.addresses.type
. (I think all do by default today without that request, but it's still a reasonable test to be sure).
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.
Dynamic would mean everything that is provider-specific, but maybe that's not the correct term
Isn't it kinda weird that for each type you would need to have a new Feature Request instead of just letting the implementation worry about it, and just make sure it conforms from our side?
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.
While I expect lots of implementation-specific values to exist here, I don't think there's really a good way to conformance test implementation-specific support like this, so I'd leave that out of scope.
@youngnick @robscott can you please re-review this? |
cdfd8c2
to
1487843
Compare
/ok-to-test |
/retest |
4cd24c2
to
687de42
Compare
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 @EyalPazz!
Hey @EyalPazz, I chatted with @youngnick about this and we agreed that it would make sense to move the conformance test for this into a follow up PR. The rationale is that as long as we have a clearly defined API spec for this, the conformance test would be covering with 99+% of implementations already do (automatically assign an IP address to a Gateway), so it's not quite as critical as we'd initially thought. Will you have time to update the PR in the next day or two to reflect this new smaller scope? Would love to get this into v1.3 if possible. |
Yea for sure, i'll do it tomorrow morning |
Should be ok now :) @robscott |
Thanks @EyalPazz! Will leave final LGTM for @youngnick or someone else. /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: EyalPazz, robscott 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 |
What type of PR is this?
/kind feature
Which issue(s) this PR fixes:
Fixes #3612
Does this PR introduce a user-facing change?: