Draft: Apply threshold to available v4 subnets
Given the current implementation, race conditions can happen when multiple machines are instantiated in the same subnet and there are no enough IPs available.
This path doesn't fix this issue, but it reduces the probability of happening by applying a certain threshold that skips the v4 subnets that are almost full.
If all the v4 subnets are over the threshold, they are all considered and the previous logic applies.
Note: this patch is currently marked as draft. To be decided whether this is the desired fix or we go for a more elaborated approach like:
- Change nova patch to use "most_available_subnet" instead, basically this block: https://gitlab.cern.ch/cloud-infrastructure/nova/-/blob/cern-train/nova/network/neutronv2/api.py#L459-466
- This would require to provide "most_available_subnet_v4" & "most_available_subnet_v6", making sure they're both in the same pool as we do for "available_random_subnet_v*".