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

Add plural IP fields to EndpointSpec #3267

Merged
merged 2 commits into from
Jan 17, 2025

Conversation

tpantelis
Copy link
Contributor

...that mirror the singular HealthCheckIP, PrivateIP and PublicIP fields to support dual-stack addresses. The singular fields are deprecated and remain to support backwards compatibility and migration with prior versions. Going forward only the plural fields will be used. Get/Set methods were added to EndpointSpec that handle the singular fields. On Get, if the plural field is empty then retrieve the singular field. On Set, if one of the specified IPs is IPv4 then set the corresponding singular field.

@submariner-bot
Copy link
Contributor

🤖 Created branch: z_pr3267/tpantelis/new_endpoint_fields
🚀 Full E2E won't run until the "ready-to-test" label is applied. I will add it automatically once the PR has 2 approvals, or you can add it manually.

return fromArrayOrString(ep.PublicIPs, ep.PublicIP)
}

func (ep *EndpointSpec) SetPublicIPs(ips ...string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

overall code LGTM,
I have one minor comment, since some of the fields (e.g Public IP) can be discovered at different timing maybe it makes sense to replace (or add new API) SetxxxIPs with UpdatexxIP (Update should call GetxxxIPs and update it if needed ) instead of having this logic in clients side

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I'm not sure I follow what you mean...

Copy link
Contributor

@yboaron yboaron Jan 16, 2025

Choose a reason for hiding this comment

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

I'm sorry, I'll try to explain it by example ...

Assuming the following use case for dual-stack case:
A. public IPV4 address successfully discovered on t1
B. public IPV6 address only discovered on t2

I thought it might be useful to have Update API (that will add IP if it doesn't exist, we can use it in step B for example).

But on second thought since there is only single client (gateway) that will call this APIs we can have this logic at the gateway side.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see - there may be cases where we need to set IPs atomically or piecemeal. Either way we can add/modify the helper functions as needed. The main point of these helpers is to hide the singular fields.

Copy link
Member

Choose a reason for hiding this comment

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

This highlights that there’s a difference between the way the data is stored and how it’s used. Externally, the API could be Set…IPv4/Set…IPv6 (with corresponding getters); that would make it explicit that the data structure only stores one IPv4 address and one IPv6 address.

(Incidentally, there’s currently nothing stopping a caller from storing two IPv4 addresses or two IPv6 addresses 😉.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK I changed the getters to retrieve the singular IP for an IP family. The family is passed as a parameter as, after looking at usages, I think that's going to be more natural/easier rather than separate functions for each family. The setters add the address if not already present to ensure there's only one per family.

@tpantelis tpantelis force-pushed the new_endpoint_fields branch from 50a3b93 to 8b13fb0 Compare January 16, 2025 15:09
@tpantelis
Copy link
Contributor Author

I made PrivateIPs and PublicIPs optional as well to allow an older cluster to create an Endpoint with the legacy singular fields.

@tpantelis tpantelis force-pushed the new_endpoint_fields branch from 746e81f to 43942b9 Compare January 16, 2025 19:51
...that mirror the singular HealthCheckIP, PrivateIP and PublicIP
fields to support dual-stack addresses. The singular fields are
deprecated and remain to support backwards compatibility and migration
with prior versions. Going forward only the plural fields will be used.
Get*IP/Add*IP methods were added to EndpointSpec that handle the singular
fields. On Get for IPv4, if the plural field doesn't contain an IPv4
address then retrieve the singular field. On Set for IPv4 also set
the corresponding singular field.

Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
@tpantelis tpantelis force-pushed the new_endpoint_fields branch from 43942b9 to c0d875a Compare January 16, 2025 20:01
@submariner-bot submariner-bot added the ready-to-test When a PR is ready for full E2E testing label Jan 17, 2025
@skitt skitt enabled auto-merge (rebase) January 17, 2025 10:46
@skitt skitt merged commit 2c0e7b5 into submariner-io:devel Jan 17, 2025
40 checks passed
@submariner-bot
Copy link
Contributor

🤖 Closed branches: [z_pr3267/tpantelis/new_endpoint_fields]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-test When a PR is ready for full E2E testing
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants