Project | LXD |
---|---|
Status | Completed |
Author(s) | @markylaing |
Approver(s) | @tomp @mionaalex @egelinas @maria-seralessandri |
Release | 6.1 |
Internal ID | LX074 |
Abstract
This specification describes why automatic allocation of listen addresses for OVN load-balancers and network forwards is required for LXD, and outlines changes to the CLI and API handlers that will be made for the implementation.
Rationale
When creating a load-balancer or network forward in an OVN network, the listen address of the load-balancer of the network forward must be specified. Networks that are defined in the default project are shared with projects that do not have features.networks
enabled. This means that when creating a network forward or load-balancer in the restricted project, the user cannot see the external addresses that are already in use, and may encounter an error that is not their fault.
Rather than exposing a list of addresses that are already in use by the network, LXD can select an address from the pool of available addresses.
Specification
The following API handlers will be modified:
POST /1.0/networks/{networkName}/forwards
POST /1.0/networks/{networkName}/load-balancers
The listen_address
field in the request body will now be allowed to be an unspecified IPv4 or IPv6 address (i.e. 0.0.0.0
or ::
).
On creation of a load balancer or network forward, the OVN network driver will ascertain whether IP addresses should be automatically allocated by checking if the listen address is unspecified. If it is unspecified, the version of the allocated IP is determined by the IP version of the unspecified listen address.
To determine an appropriate IP address, the OVN network driver will:
- Collate subnets from
restricted.networks.subnets
, if set on the parent project. Otherwise, the subnets inipv{4,6}.routes
will be used. - Re-order those subnets so that the order by which the subnet is chosen is random.
- Iterate over the re-ordered subnets, picking a random IP address until one is found that is not already in use.
The process for selecting a random valid IP address will time out after 5 seconds. If one is not found, an error will be returned to the user indicating that manual configuration may be required.
Future work
If two load balancer or network forward creation requests are received concurrently, it is possible for the same address to be selected by the OVN driver. However, one request will ultimately fail when OVN attempts to create the resource. In this case, all previous logic is appropriately reverted. It may be possible to prevent this from occurring by introducing a cluster-wide lock. In the meantime, the initial implementation reduces this risk by opting to use a random IP address in the range, rather than the next available IP.
API changes
None
CLI changes
The following commands will change:
lxc network forward create <network-name> <listen-address>
lxc network load-balancer create <network-name> <listen-address>
In both cases, the <listen-address>
argument will be made optional. A new --allocate
flag will be introduced which will accept two values: ipv4
or ipv6
. If the --allocate=ipv4
is provided, the CLI will use an unspecified IPv4 address as the listen address (and vice versa for IPv6).
Database changes
None
Upgrade handling
None