Don't update the management port when calculating delta

CalculateDelta should be used to get the list of subnets/networks to
plug (or unplug) into the amphora for the VIP and the members.
It should never reconfigure the management port.

Story 2010623
Task 47564

Change-Id: Iccae6ec561603653183911146a638272df631e92
This commit is contained in:
Gregory Thiemonge 2023-03-02 03:30:52 -05:00
parent 12d8e0de5d
commit 8ccc0d0176
3 changed files with 17 additions and 24 deletions

View File

@ -55,16 +55,10 @@ class CalculateAmphoraDelta(BaseNetworkTask):
default_provides = constants.DELTA default_provides = constants.DELTA
# TODO(gthiemonge) ensure we no longer need vrrp_port
def execute(self, loadbalancer, amphora, availability_zone): def execute(self, loadbalancer, amphora, availability_zone):
LOG.debug("Calculating network delta for amphora id: %s", LOG.debug("Calculating network delta for amphora id: %s",
amphora.get(constants.ID)) amphora.get(constants.ID))
vip_subnet_to_net_map = {
loadbalancer[constants.VIP_SUBNET_ID]:
loadbalancer[constants.VIP_NETWORK_ID]
}
# Figure out what networks we want # Figure out what networks we want
# seed with lb network(s) # seed with lb network(s)
if (availability_zone and if (availability_zone and
@ -77,12 +71,10 @@ class CalculateAmphoraDelta(BaseNetworkTask):
db_lb = self.loadbalancer_repo.get( db_lb = self.loadbalancer_repo.get(
db_apis.get_session(), id=loadbalancer[constants.LOADBALANCER_ID]) db_apis.get_session(), id=loadbalancer[constants.LOADBALANCER_ID])
desired_subnet_to_net_map = {} desired_subnet_to_net_map = {
for mgmt_net_id in management_nets: loadbalancer[constants.VIP_SUBNET_ID]:
for subnet_id in self.network_driver.get_network( loadbalancer[constants.VIP_NETWORK_ID]
mgmt_net_id).subnets: }
desired_subnet_to_net_map[subnet_id] = mgmt_net_id
desired_subnet_to_net_map.update(vip_subnet_to_net_map)
for pool in db_lb.pools: for pool in db_lb.pools:
for member in pool.members: for member in pool.members:
@ -101,7 +93,12 @@ class CalculateAmphoraDelta(BaseNetworkTask):
nics = self.network_driver.get_plugged_networks( nics = self.network_driver.get_plugged_networks(
amphora[constants.COMPUTE_ID]) amphora[constants.COMPUTE_ID])
# we don't have two nics in the same network # we don't have two nics in the same network
network_to_nic_map = {nic.network_id: nic for nic in nics} # Don't include the nics connected to the management network, we don't
# want to update these interfaces.
network_to_nic_map = {
nic.network_id: nic
for nic in nics
if nic.network_id not in management_nets}
plugged_network_ids = set(network_to_nic_map) plugged_network_ids = set(network_to_nic_map)

View File

@ -185,7 +185,6 @@ class TestNetworkTasks(base.TestCase):
mock_lb_repo_get.return_value = lb_mock mock_lb_repo_get.return_value = lb_mock
mock_driver.get_port.return_value = vrrp_port mock_driver.get_port.return_value = vrrp_port
mock_driver.get_subnet.return_value = member_subnet mock_driver.get_subnet.return_value = member_subnet
mock_driver.get_network.return_value = mgmt_net
mock_driver.get_plugged_networks.return_value = [ mock_driver.get_plugged_networks.return_value = [
mgmt_interface, mgmt_interface,
vrrp_interface, vrrp_interface,
@ -231,9 +230,6 @@ class TestNetworkTasks(base.TestCase):
mgmt_subnet = data_models.Subnet( mgmt_subnet = data_models.Subnet(
id=self.mgmt_subnet_id, network_id=self.mgmt_net_id) id=self.mgmt_subnet_id, network_id=self.mgmt_net_id)
mgmt_net = data_models.Network(
id=self.mgmt_net_id,
subnets=[mgmt_subnet.id])
mgmt_ip_address = mock.MagicMock() mgmt_ip_address = mock.MagicMock()
mgmt_interface = data_models.Interface( mgmt_interface = data_models.Interface(
network_id=self.mgmt_net_id, network_id=self.mgmt_net_id,
@ -304,7 +300,6 @@ class TestNetworkTasks(base.TestCase):
fixed_ips=vrrp_port.fixed_ips)] fixed_ips=vrrp_port.fixed_ips)]
mock_driver.get_port.return_value = vrrp_port mock_driver.get_port.return_value = vrrp_port
mock_driver.get_subnet.return_value = vrrp_subnet mock_driver.get_subnet.return_value = vrrp_subnet
mock_driver.get_network.return_value = mgmt_net
calc_delta = network_tasks.CalculateDelta() calc_delta = network_tasks.CalculateDelta()
@ -407,10 +402,6 @@ class TestNetworkTasks(base.TestCase):
mgmt2_subnet = data_models.Subnet( mgmt2_subnet = data_models.Subnet(
id=mgmt2_subnet_id, id=mgmt2_subnet_id,
network_id=mgmt2_net_id) network_id=mgmt2_net_id)
mgmt2_net = data_models.Network(
id=mgmt2_net_id,
subnets=[mgmt2_subnet.id]
)
mgmt2_interface = data_models.Interface( mgmt2_interface = data_models.Interface(
network_id=mgmt2_net_id, network_id=mgmt2_net_id,
fixed_ips=[ fixed_ips=[
@ -419,7 +410,6 @@ class TestNetworkTasks(base.TestCase):
subnet_id=mgmt2_subnet_id, subnet_id=mgmt2_subnet_id,
) )
]) ])
mock_driver.get_network.return_value = mgmt2_net
az = { az = {
constants.MANAGEMENT_NETWORK: mgmt2_net_id, constants.MANAGEMENT_NETWORK: mgmt2_net_id,
} }
@ -439,7 +429,6 @@ class TestNetworkTasks(base.TestCase):
# Test with one amp and one pool and one member, wrong network plugged # Test with one amp and one pool and one member, wrong network plugged
# Delta should be one network/subnet to add and one to remove # Delta should be one network/subnet to add and one to remove
mock_driver.reset_mock() mock_driver.reset_mock()
mock_driver.get_network.return_value = mgmt_net
member_mock = mock.MagicMock() member_mock = mock.MagicMock()
member_mock.subnet_id = member_private_subnet.id member_mock.subnet_id = member_private_subnet.id
pool_mock.members = [member_mock] pool_mock.members = [member_mock]

View File

@ -0,0 +1,7 @@
---
fixes:
- |
Fixed an issue when adding or deleting a member, Octavia might have
reconfigured the management port of the amphora by adding or removing
additional subnets. Octavia no longer updates the management port during
those tasks.