Closed Tiboris closed 2 years ago
Adding basic tests and will add more, just creating skeleton
I have added
async def test_network_picking_validation(self, x):
which should test new way of picking networks. This MR from my POV can be reviewed now.
I'm missing in the patch the part which we discuss in person - keep the original behavior (all hosts has the same network picked) for the usual cases.
Hello @pvoborni I find this part very sad because:
I would really like to convince you that this is nothing bad from the perspective of picking the networks. So far there are no issues and I would rather to create such patch as a quick fix if there is something wrong with this approach (even if you consider this unsafe development path). Would you give it a try?
I'd also consider if we should not create a new module for openstack network switching
If I understood correctly you mean something like we have with provisioning_base and strategies.
I have updated docstrings for the methods which are network_pick related. I have extracted the text from commit message and added few examples.
I have added tests for 0 hosts available to test corner-case with no IPs left.
regression runs passing, merging
With this patch OpenStack is able to pick Network from all of networks based on network load and requirement got from the metadata. Each of required host gets its own position, aka weigh in interval <0, 1> based on the order (index) in metadata. Before that all of the networks are 'normalized' in a way that the random selection from subset of networks (or all of network if number of hosts > number of networks) is divided to effective range (multiple intervals <0, 1>) for the network based on the relative network weight compared to full capacity of considered networks.
An example:
Host weights:
Network availability:
Full capacity of these 5 nets: 500
Normalized network range: net 4 - <0, 0.29> net 3 - (0,29, 0.55> net 5 - (0.55, 0.76> net 2 - (0.76, 0.96> net 1 - (0.96, 1>
Which will divide networks for hosts: host 1 => net 4 (0 falls into net 4 interval) host 2 => net 4 (0.2 falls into net 4 interval) host 3 => net 3 (0.4 falls into net 3 interval) host 4 => net 5 (0.6 falls into net 5 interval) host 5 => net 2 (0.8 falls into net 2 interval)
net 1 will be unused as bigger networks are preferred this way.