Fix management network selection when calculating deltas

Providing an AZ dict without the 'management_network' field to
CalculateAmphoraDelta task broke the calculation of the interfaces to be
deleted. As a result, the management interface might have been removed
by the HandleNetworkDelta task.

Change-Id: I72796b3ed1c3f180cca8c005fdbad81d9dbef37d
This commit is contained in:
Gregory Thiemonge 2021-09-24 21:41:08 +02:00
parent 4e02b7639d
commit b41b275b83
2 changed files with 9 additions and 5 deletions

View File

@ -69,10 +69,10 @@ class CalculateAmphoraDelta(BaseNetworkTask):
# Figure out what networks we want
# seed with lb network(s)
if availability_zone:
management_nets = (
[availability_zone.get(constants.MANAGEMENT_NETWORK)] or
CONF.controller_worker.amp_boot_network_list)
if (availability_zone and
availability_zone.get(constants.MANAGEMENT_NETWORK)):
management_nets = [
availability_zone.get(constants.MANAGEMENT_NETWORK)]
else:
management_nets = CONF.controller_worker.amp_boot_network_list
desired_network_ids = {vrrp_port_network_id}.union(management_nets)

View File

@ -230,11 +230,15 @@ class TestNetworkTasks(base.TestCase):
calc_delta.execute(self.load_balancer_mock, {}))
# Test with one amp and one pool and one member, nothing plugged
# Dummy AZ is provided
# Delta should be one additional subnet to plug
mock_driver.reset_mock()
member_mock = mock.MagicMock()
member_mock.subnet_id = 1
pool_mock.members = [member_mock]
az = {
constants.COMPUTE_ZONE: 'foo'
}
mock_driver.get_subnet.return_value = data_models.Subnet(id=2,
network_id=3)
@ -244,7 +248,7 @@ class TestNetworkTasks(base.TestCase):
data_models.Interface(network_id=3)],
delete_nics=[]).to_dict(recurse=True)
self.assertEqual({self.db_amphora_mock.id: ndm},
calc_delta.execute(self.load_balancer_mock, {}))
calc_delta.execute(self.load_balancer_mock, az))
vrrp_port_call = mock.call(PORT_ID)
mock_driver.get_port.assert_has_calls([vrrp_port_call])