diff --git a/octavia/controller/worker/v2/tasks/network_tasks.py b/octavia/controller/worker/v2/tasks/network_tasks.py index 87759e57fa..6e715dff9c 100644 --- a/octavia/controller/worker/v2/tasks/network_tasks.py +++ b/octavia/controller/worker/v2/tasks/network_tasks.py @@ -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) diff --git a/octavia/tests/unit/controller/worker/v2/tasks/test_network_tasks.py b/octavia/tests/unit/controller/worker/v2/tasks/test_network_tasks.py index f4a0a1a2b6..b2e0eb609d 100644 --- a/octavia/tests/unit/controller/worker/v2/tasks/test_network_tasks.py +++ b/octavia/tests/unit/controller/worker/v2/tasks/test_network_tasks.py @@ -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])