Open lukego opened 9 years ago
The feature as described here is more or less implemented.
There is an issue though. The procedure here is detailing the port/IP allocation but not the deallocation.
What shall be the behavior when the port is deleted?
Let's look at the example where we have allocated 10.0.1.1
, 10.0.1.2
and 10.0.1.3
. Then we delete the port which uses 10.0.1.2
, and we try to bind a new port? Which IP shall be the next? Is it 10.0.1.2
or 10.0.1.4
?
Other issue is when the IPs get exhausted, shall bind_port()
faill if on 10.0.1.0/24
we try to allocate 10.0.1.255
?
When a port is deleted its address should be returned to the pool for reuse.
New ports can use any available address, it does not matter if the address is being reused after deletion or was never used before.
If no addresses are available then port binding should fail. (This should cause nova boot
to try a new machine that may have addresses available.)
Does that answer the questions?
One more issue, in the DT lab the GW IP address is SUBNET+1. I have made a "temporary" hack/fix: https://github.com/virtualopensystems/neutron/commit/ea2229ad875f7f037132f51ce953382c03f65f4c#diff-3a556bea9bd62b66915aee3fed33871dR221
It basically marks all SUBNET+1 addresses as already used, so not available. Is there a better idea?
Currently we waste some IP addresses. This is not okay for IPv4 because so few addresses are available.
The issue is that we assign globally-unique "template addresses" (
0.0.0.1
,0.0.0.2
,0.0.0.3
, etc) and then move these into real subnets. However, it is overkill for these addresses to be globally unique. They only need to be unique within the real subnet that is eventually chosen.For example, suppose we have three subnets (
10.0.1.0/28
,10.0.2.0/28
,10.0.3.0/28
) and we create one port in each one. Today the addresses we would assign are10.0.1.1
,10.0.2.2
, and10.0.3.3
. Instead we want to allocate10.0.1.1
,10.0.2.1
, and10.0.3.1
i.e. the first available addresses for each subnet individually.Hopefully Neutron already has a database-backed IP address allocation class that we can reuse for this purpose. (The state has to be stored in the database because there could be several copies of the Python code running on different machines.)
This has to be done for IPv4. IPv6 is optional: whatever makes the code simpler. (IPv6 has no address shortage to worry about.)
This feature would probably be implemented in the
bind_port()
Python function.@n-nikolaev