Fix sync for OVN LB VIPs
There was a bad comparison of datapath types, we compared router datapath is equal to loadbalancer datapaths instead of if it is included there. Closes-bug: #2064922 Change-Id: I4f92d75f512ca906ad884e9da21ee7048b1dc5d6 Signed-off-by: Jakub Libosvar <libosvar@redhat.com>
This commit is contained in:
parent
bdbf573ae4
commit
8cda2174db
@ -777,21 +777,21 @@ class OvsdbSbOvnIdl(sb_impl_idl.OvnSbApiIdlImpl, Backend):
|
|||||||
lb = self.get_ovn_lb(lb_name)
|
lb = self.get_ovn_lb(lb_name)
|
||||||
if not lb:
|
if not lb:
|
||||||
continue
|
continue
|
||||||
lb_dp, lr_dp = helpers.get_lb_datapath_groups(lb)
|
lb_dps, lr_dps = helpers.get_lb_datapaths(lb)
|
||||||
if not lb_dp:
|
if not lb_dps:
|
||||||
lb_dp = lb.datapaths
|
lb_dps = lb.datapaths
|
||||||
|
|
||||||
if not lr_dp:
|
if not lr_dps:
|
||||||
# assume all the members are connected through the same router
|
# assume all the members are connected through the same router
|
||||||
# so only one datapath needs to be checked
|
# so only one datapath needs to be checked
|
||||||
router_lrps = self.get_lrps_for_datapath(lb_dp[0])
|
router_lrps = self.get_lrps_for_datapath(lb_dps[0])
|
||||||
for lrp in router_lrps:
|
for lrp in router_lrps:
|
||||||
router_lrp_dp = self.get_port_datapath(lrp)
|
router_lrp_dp = self.get_port_datapath(lrp)
|
||||||
if router_lrp_dp == router_dp:
|
if router_lrp_dp == router_dp:
|
||||||
lb_ip = ip_info.split(" ")[0].split("/")[0]
|
lb_ip = ip_info.split(" ")[0].split("/")[0]
|
||||||
lbs[lb.name] = lb_ip
|
lbs[lb.name] = lb_ip
|
||||||
break
|
break
|
||||||
elif lr_dp == router_dp:
|
elif router_dp in lr_dps:
|
||||||
lb_ip = ip_info.split(" ")[0].split("/")[0]
|
lb_ip = ip_info.split(" ")[0].split("/")[0]
|
||||||
lbs[lb.name] = lb_ip
|
lbs[lb.name] = lb_ip
|
||||||
|
|
||||||
|
@ -397,12 +397,12 @@ class OVNLBMemberCreateEvent(base_watcher.OVNLBEvent):
|
|||||||
if not self.agent.ovn_local_cr_lrps:
|
if not self.agent.ovn_local_cr_lrps:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
row_dp = row.datapaths
|
row_dps = row.datapaths
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
row_dp = []
|
row_dps = []
|
||||||
|
|
||||||
row_dp, router_dps = helpers.get_lb_datapath_groups(row)
|
row_dps, router_dps = helpers.get_lb_datapaths(row)
|
||||||
if not row_dp:
|
if not row_dps:
|
||||||
# No need to continue. There is no need to expose it as there is
|
# No need to continue. There is no need to expose it as there is
|
||||||
# no datapaths (aka members).
|
# no datapaths (aka members).
|
||||||
return
|
return
|
||||||
@ -419,7 +419,7 @@ class OVNLBMemberCreateEvent(base_watcher.OVNLBEvent):
|
|||||||
CONF.expose_ipv6_gua_tenant_networks):
|
CONF.expose_ipv6_gua_tenant_networks):
|
||||||
# assume all the members are connected through the same router
|
# assume all the members are connected through the same router
|
||||||
# so only one member needs to be checked
|
# so only one member needs to be checked
|
||||||
member_dp = row_dp[0]
|
member_dp = row_dps[0]
|
||||||
# get lrps on that dp (patch ports)
|
# get lrps on that dp (patch ports)
|
||||||
router_lrps = (
|
router_lrps = (
|
||||||
self.agent.sb_idl.get_lrps_for_datapath(member_dp))
|
self.agent.sb_idl.get_lrps_for_datapath(member_dp))
|
||||||
@ -430,7 +430,7 @@ class OVNLBMemberCreateEvent(base_watcher.OVNLBEvent):
|
|||||||
if vip_port.datapath != cr_lrp_info.get('provider_datapath'):
|
if vip_port.datapath != cr_lrp_info.get('provider_datapath'):
|
||||||
continue
|
continue
|
||||||
if cr_lrp_info.get('subnets_datapath'):
|
if cr_lrp_info.get('subnets_datapath'):
|
||||||
if set(row_dp).intersection(set(
|
if set(row_dps).intersection(set(
|
||||||
cr_lrp_info.get('subnets_datapath').values())):
|
cr_lrp_info.get('subnets_datapath').values())):
|
||||||
associated_cr_lrp_port = cr_lrp_port
|
associated_cr_lrp_port = cr_lrp_port
|
||||||
break
|
break
|
||||||
|
@ -44,32 +44,32 @@ class TestHelpers(test_base.TestCase):
|
|||||||
self.assertEqual(ret_bridge, None)
|
self.assertEqual(ret_bridge, None)
|
||||||
|
|
||||||
|
|
||||||
class TestHelperGetLBDatapathGroup(test_base.TestCase):
|
class TestHelperGetLBDatapaths(test_base.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestHelperGetLBDatapathGroup, self).setUp()
|
super().setUp()
|
||||||
self.dp_group = utils.create_row(_uuid='fake_dp_group',
|
self.dp_group = utils.create_row(_uuid='fake_dp_group',
|
||||||
datapaths=['dp'])
|
datapaths=['dp'])
|
||||||
self.dp_group1 = utils.create_row(_uuid='fake_dp_group1',
|
self.dp_group1 = utils.create_row(_uuid='fake_dp_group1',
|
||||||
datapaths=['dp1'])
|
datapaths=['dp1'])
|
||||||
|
|
||||||
def test_get_lb_datapath_group(self):
|
def test_get_lb_datapaths(self):
|
||||||
lb = utils.create_row(name='ovn-lb',
|
lb = utils.create_row(name='ovn-lb',
|
||||||
datapath_group=[self.dp_group])
|
datapath_group=[self.dp_group])
|
||||||
self.assertEqual((['dp'], []), helpers.get_lb_datapath_groups(lb))
|
self.assertEqual((['dp'], []), helpers.get_lb_datapaths(lb))
|
||||||
|
|
||||||
def test_get_lb_datapath_group_ls_datapath(self):
|
def test_get_lb_datapaths_ls_datapath(self):
|
||||||
lb = utils.create_row(name='ovn-lb',
|
lb = utils.create_row(name='ovn-lb',
|
||||||
ls_datapath_group=[self.dp_group])
|
ls_datapath_group=[self.dp_group])
|
||||||
self.assertEqual((['dp'], []), helpers.get_lb_datapath_groups(lb))
|
self.assertEqual((['dp'], []), helpers.get_lb_datapaths(lb))
|
||||||
|
|
||||||
def test_get_lb_datapath_group_lr_datapath(self):
|
def test_get_lb_datapaths_lr_datapath(self):
|
||||||
lb = utils.create_row(name='ovn-lb',
|
lb = utils.create_row(name='ovn-lb',
|
||||||
lr_datapath_group=[self.dp_group])
|
lr_datapath_group=[self.dp_group])
|
||||||
self.assertEqual(([], ['dp']), helpers.get_lb_datapath_groups(lb))
|
self.assertEqual(([], ['dp']), helpers.get_lb_datapaths(lb))
|
||||||
|
|
||||||
def test_get_lb_datapath_group_ls_and_lr_datapath(self):
|
def test_get_lb_datapaths_ls_and_lr_datapath(self):
|
||||||
lb = utils.create_row(name='ovn-lb',
|
lb = utils.create_row(name='ovn-lb',
|
||||||
ls_datapath_group=[self.dp_group],
|
ls_datapath_group=[self.dp_group],
|
||||||
lr_datapath_group=[self.dp_group1])
|
lr_datapath_group=[self.dp_group1])
|
||||||
self.assertEqual((['dp'], ['dp1']), helpers.get_lb_datapath_groups(lb))
|
self.assertEqual((['dp'], ['dp1']), helpers.get_lb_datapaths(lb))
|
||||||
|
@ -27,21 +27,21 @@ def parse_bridge_mapping(bridge_mapping):
|
|||||||
return network, bridge
|
return network, bridge
|
||||||
|
|
||||||
|
|
||||||
def _get_lb_datapath_group(lb, attr):
|
def _get_lb_datapaths_from_group(lb, attr):
|
||||||
try:
|
try:
|
||||||
dp = getattr(lb, attr)[0].datapaths
|
dps = getattr(lb, attr)[0].datapaths
|
||||||
if dp:
|
if dps:
|
||||||
return dp
|
return dps
|
||||||
except (AttributeError, IndexError):
|
except (AttributeError, IndexError):
|
||||||
pass
|
pass
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
def get_lb_datapath_groups(lb):
|
def get_lb_datapaths(lb):
|
||||||
for attr in ('ls_datapath_group', 'datapath_group'):
|
for attr in ('ls_datapath_group', 'datapath_group'):
|
||||||
ls_dp = _get_lb_datapath_group(lb, attr)
|
ls_dps = _get_lb_datapaths_from_group(lb, attr)
|
||||||
if ls_dp:
|
if ls_dps:
|
||||||
break
|
break
|
||||||
|
|
||||||
lr_dp = _get_lb_datapath_group(lb, 'lr_datapath_group')
|
lr_dps = _get_lb_datapaths_from_group(lb, 'lr_datapath_group')
|
||||||
return (ls_dp, lr_dp)
|
return (ls_dps, lr_dps)
|
||||||
|
Loading…
Reference in New Issue
Block a user