Remove LB from LS belonging to provider networks
In core OVN, LBs on switches with localnet ports (i.e., neutron provider networks) don't work if traffic comes from localnet [1] In order to force NAT to happen at the virtual router instead of the LS level, when the VIP of the LoadBalancer is associated to a provider network we should avoid adding the LB to the LS associated to the provider network [1] https://bugzilla.redhat.com/show_bug.cgi?id=2164652 Closes-Bug: #2003997 Change-Id: I009ddd2604d208bbf793e2d19d4195b77726f7b2
This commit is contained in:
parent
ef019ed63b
commit
46ddbf3168
|
@ -18,6 +18,7 @@ import re
|
|||
import threading
|
||||
|
||||
import netaddr
|
||||
from neutron_lib.api.definitions import provider_net
|
||||
from neutron_lib import constants as n_const
|
||||
from neutronclient.common import exceptions as n_exc
|
||||
from octavia_lib.api.drivers import data_models as o_datamodels
|
||||
|
@ -989,11 +990,17 @@ class OvnProviderHelper():
|
|||
loadbalancer[constants.ID],
|
||||
protocol=protocol)
|
||||
ovn_lb = ovn_lb if protocol else ovn_lb[0]
|
||||
# NOTE(froyo): This is the association of the lb to the VIP ls
|
||||
# so this is executed right away
|
||||
self._update_lb_to_ls_association(
|
||||
ovn_lb, network_id=port['network_id'],
|
||||
associate=True, update_ls_ref=True)
|
||||
|
||||
# NOTE(ltomasbo): If the VIP is on a provider network, it does
|
||||
# not need to be associated to its LS
|
||||
network = neutron_client.show_network(
|
||||
port['network_id'])['network']
|
||||
if not network.get(provider_net.PHYSICAL_NETWORK, False):
|
||||
# NOTE(froyo): This is the association of the lb to the VIP ls
|
||||
# so this is executed right away
|
||||
self._update_lb_to_ls_association(
|
||||
ovn_lb, network_id=port['network_id'],
|
||||
associate=True, update_ls_ref=True)
|
||||
ls_name = utils.ovn_name(port['network_id'])
|
||||
ovn_ls = self.ovn_nbdb_api.ls_get(ls_name).execute(
|
||||
check_error=True)
|
||||
|
|
|
@ -57,6 +57,7 @@ class TestOvnOctaviaBase(base.TestOVNFunctionalBase,
|
|||
self.fake_neutron_client = mock.MagicMock()
|
||||
clients.get_neutron_client = mock.MagicMock()
|
||||
clients.get_neutron_client.return_value = self.fake_neutron_client
|
||||
self.fake_neutron_client.show_network = self._mock_show_network
|
||||
self.fake_neutron_client.show_subnet = self._mock_show_subnet
|
||||
self.fake_neutron_client.list_ports = self._mock_list_ports
|
||||
self.fake_neutron_client.show_port = self._mock_show_port
|
||||
|
@ -66,6 +67,12 @@ class TestOvnOctaviaBase(base.TestOVNFunctionalBase,
|
|||
self._local_port_cache = {'ports': []}
|
||||
self.core_plugin = directory.get_plugin()
|
||||
|
||||
def _mock_show_network(self, network_id):
|
||||
network = {}
|
||||
network['id'] = network_id
|
||||
network['provider:physical_network'] = None
|
||||
return {'network': network}
|
||||
|
||||
def _mock_show_subnet(self, subnet_id):
|
||||
subnet = {}
|
||||
subnet['network_id'] = self._local_net_cache[subnet_id]
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
import copy
|
||||
from unittest import mock
|
||||
|
||||
from neutron_lib.api.definitions import provider_net
|
||||
from neutron_lib import constants as n_const
|
||||
from neutronclient.common import exceptions as n_exc
|
||||
from octavia_lib.api.drivers import data_models
|
||||
|
@ -654,6 +655,11 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
|
|||
self.lb[ovn_const.LB_EXT_IDS_LR_REF_KEY] = 'foo'
|
||||
self.lb[ovn_const.LB_EXT_IDS_LS_REFS_KEY] = '{\"neutron-foo\": 1}'
|
||||
net_cli.return_value.list_ports.return_value = self.ports
|
||||
fake_network = {'id': self.lb['vip_network_id'],
|
||||
provider_net.PHYSICAL_NETWORK: None}
|
||||
net_cli.return_value.show_network.return_value = {
|
||||
'network': fake_network}
|
||||
|
||||
status = self.helper.lb_create(self.lb, protocol=protocol)
|
||||
self.assertEqual(status['loadbalancers'][0]['provisioning_status'],
|
||||
constants.ACTIVE)
|
||||
|
|
Loading…
Reference in New Issue