-
Notifications
You must be signed in to change notification settings - Fork 985
Network: Internal OVN load balancers and forwards #16162
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
Conversation
| SELECT | ||
| projects.name, | ||
| networks.name, | ||
| networks_load_balancers.listen_address | ||
| networks.type, | ||
| networks_load_balancers.listen_address, | ||
| nc_ipv4.value AS ipv4_address, | ||
| nc_ipv6.value AS ipv6_address | ||
| FROM networks_load_balancers | ||
| JOIN networks on networks.id = networks_load_balancers.network_id | ||
| JOIN networks_config on networks.id = networks_config.network_id | ||
| JOIN networks ON networks.id = networks_load_balancers.network_id | ||
| JOIN projects ON projects.id = networks.project_id | ||
| JOIN networks_config AS nc_filter on networks.id = nc_filter.network_id | ||
| LEFT JOIN networks_config AS nc_ipv4 ON networks.id = nc_ipv4.network_id AND nc_ipv4.key = 'ipv4.address' | ||
| LEFT JOIN networks_config AS nc_ipv6 ON networks.id = nc_ipv6.network_id AND nc_ipv6.key = 'ipv6.address' | ||
| WHERE ( | ||
| (networks_config.key = "network" AND networks_config.value = ?1) | ||
| (nc_filter.key = "network" AND nc_filter.value = ?1) | ||
| OR (projects.name = "default" AND networks.name = ?1) | ||
| ) | ||
| `) |
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 query is used in:
lxd/lxd/network/driver_common.go
Line 214 in 7b3a50b
| func (n *common) validateRoutes(config map[string]string) error { |
lxd/lxd/network/driver_common.go
Line 1224 in 7b3a50b
| func (n *common) getExternalSubnetInUse(ctx context.Context, tx *db.ClusterTx, uplinkNetworkName string, memberSpecific bool) ([]externalSubnetUsage, error) { |
lxd/lxd/project/limits/permissions.go
Line 1770 in 7b3a50b
| func UplinkAddressQuotasExceeded(ctx context.Context, tx *db.ClusterTx, projectName string, networkName string, uplinkIPV4Quota int, uplinkIPV6Quota int, projectNetworks map[int64]api.Network) (V4QuotaExceeded bool, V6QuotaExceeded bool, err error) { |
In all these contexts, it is safe to omit listen addresses that are internal OVN IPs.
But alternatively, I can add an additional bool parameter (i.e., externalOnly) to the GetProjectNetworkLoadBalancerListenAddressesByUplink() function signature to explicitly determine whether internal listen addresses should be filtered out.
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.
at least you should update the function's comment to explain it I think.
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.
Makes sense, I'll update it
7920bdd to
6e7dc46
Compare
…isten addresses by uplink Update the `GetProjectNetworkLoadBalancerListenAddressesByUplink()` function to skip the listen addresses that are internal OVN IPs. Internal OVN IPs are not dependent on the uplink's IP routes. Signed-off-by: Nikita Mezhenskyi <[email protected]>
…addresses by uplink Update the `GetProjectNetworkForwardListenAddressesByUplink()` function to skip the listen addresses that are internal OVN IPs. Internal OVN IPs are not dependent on the uplink's IP routes. Signed-off-by: Nikita Mezhenskyi <[email protected]>
…balancers Allow using internal OVN IP as a listen address for OVN network forwards and load balancers. Ensure proper validation for internal OVN IPs used as listen addresses. Signed-off-by: Nikita Mezhenskyi <[email protected]>
Signed-off-by: Nikita Mezhenskyi <[email protected]>
6e7dc46 to
2d3e224
Compare
| return true, fmt.Errorf("Listen address %q is already in use by %q of network %q", listenAddress, netIPKey, n.name) | ||
| } | ||
|
|
||
| var forwards map[int64]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.
tip:
var forwards, loadBalancers map[int64]string
tomponline
left a comment
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!
Things to follow up on:
- Add functional tests to
lxd-cifor internal load balancers and forwarders (in addition to the thorough validation logic tests youve added here). - Update docs with mention of this capability - please also add an API extension to document programatically this new capability.
- Address minor comments in PR.
This PR adds tests to check that internal load balancers and forwards are reachable from inside of the OVN network, but are unreachable from outside. Follow-up to canonical/lxd#16162. This should be merged together with canonical/lxd#16179 (adds `ovn_internal_load_balancer` API extension for LXD).
Follow-up to #16162. ## Changes: - Updated the documentation with mention of ability to use internal IPs for OVN load balancers and network forwards. - Added API extension `ovn_internal_load_balancer`. - Addressed code improvement comments from the original PR.
This PR adds support for internal OVN load balancers and network forwards, enabling the use of internal OVN IPs as a listen address.
Changes:
GetProjectNetworkLoadBalancerListenAddressesByUplink()andGetProjectNetworkForwardListenAddressesByUplink()functions to skip listen addresses that are internal OVN IPs. This is needed for the following functions to work correctly with the introduction of internal load balancers and network forwards:lxd/lxd/network/driver_common.go
Line 214 in 7b3a50b
lxd/lxd/network/driver_common.go
Line 1224 in 7b3a50b
lxd/lxd/project/limits/permissions.go
Line 1770 in 7b3a50b
Updated
allocateUplinkAddress()function for OVN networks to allow allocating internal OVN IPs for load balancers and network forwards.Added
checkInternalAddressNotInUse()function for OVN networks to validate internal OVN IPs before allocation.