Add full support for OVN NB "Gateway_Chassis" table

This table is supported since OVN v20.03.

Closes-Bug: #2008077
Change-Id: I3022f6cb2ecb2d342f6fcb43835f378308c3cb96
This commit is contained in:
Rodolfo Alonso Hernandez 2023-02-18 05:55:23 +01:00 committed by Rodolfo Alonso
parent 9d5d706f7b
commit 999116126e
3 changed files with 38 additions and 30 deletions

View File

@ -49,6 +49,7 @@ DNSMASQ_VERSION_HOST_ADDR6_LIST = '2.81'
DIRECT_PORT_QOS_MIN_OVS_VERSION = '2.11'
MINIMUM_DIBBLER_VERSION = '1.0.1'
CONNTRACK_GRE_MODULE = 'nf_conntrack_proto_gre'
OVN_NB_DB_SCHEMA_GATEWAY_CHASSIS = '5.7'
OVN_NB_DB_SCHEMA_PORT_GROUP = '5.11'
OVN_NB_DB_SCHEMA_STATELESS_NAT = '5.17'
OVN_SB_DB_SCHEMA_VIRTUAL_PORT = '2.5'
@ -642,3 +643,17 @@ def ovn_sb_db_schema_virtual_port_supported():
'Exception: %s', e)
return False
return True
def ovn_nb_db_schema_gateway_chassis_supported():
try:
ver = _get_ovn_version(OVNCheckType.nb_db_schema)
minver = versionutils.convert_version_to_tuple(
OVN_NB_DB_SCHEMA_GATEWAY_CHASSIS)
if ver < minver:
return False
except (OSError, RuntimeError, ValueError) as e:
LOG.debug('Exception while checking OVN DB schema version. '
'Exception: %s', e)
return False
return True

View File

@ -339,6 +339,14 @@ def check_ovn_sb_db_schema_virtual_port():
return result
def check_ovn_nb_db_schema_gateway_chassis():
result = checks.ovn_nb_db_schema_gateway_chassis_supported()
if not result:
LOG.warning('OVN NB DB schema does not support "Chassis_Gateway" '
'table. This support was added in DB schema version 5.7.')
return result
# Define CLI opts to test specific features, with a callback for the test
OPTS = [
BoolOptCallback('ovs_vxlan', check_ovs_vxlan, default=False,
@ -419,6 +427,10 @@ OPTS = [
check_ovn_sb_db_schema_virtual_port,
help=_('Check OVN SB DB schema support virtual ports'),
default=False),
BoolOptCallback('ovn_nb_db_schema_gateway_chassis_support',
check_ovn_nb_db_schema_gateway_chassis,
help=_('Check OVN NB DB schema support Gateway_Chassis'),
default=False),
]
@ -469,6 +481,7 @@ def enable_tests_from_config():
cfg.CONF.set_default('ovn_nb_db_schema_port_group_support', True)
cfg.CONF.set_default('ovn_nb_db_schema_stateless_nat_support', True)
cfg.CONF.set_default('ovn_sb_db_schema_virtual_port_support', True)
cfg.CONF.set_default('ovn_nb_db_schema_gateway_chassis_support', True)
def all_tests_passed():

View File

@ -87,12 +87,8 @@ class TestRouter(base.TestOVNFunctionalBase):
self.sb_api.tables['Chassis'].rows.values()]
for row in self.nb_api.tables[
'Logical_Router_Port'].rows.values():
if self._l3_ha_supported():
chassis = [gwc.chassis_name for gwc in row.gateway_chassis]
self.assertCountEqual(expected, chassis)
else:
rc = row.options.get(ovn_const.OVN_GATEWAY_CHASSIS_KEY)
self.assertIn(rc, expected)
chassis = [gwc.chassis_name for gwc in row.gateway_chassis]
self.assertCountEqual(expected, chassis)
def _check_gateway_chassis_candidates(self, candidates,
router_az_hints=None):
@ -217,11 +213,6 @@ class TestRouter(base.TestOVNFunctionalBase):
# Test if chassis1 is selected as candidate or not.
self._check_gateway_chassis_candidates([self.chassis1])
def _l3_ha_supported(self):
# If the Gateway_Chassis table exists in SB database, then it
# means that L3 HA is supported.
return self.nb_api.tables.get('Gateway_Chassis')
def test_gateway_chassis_least_loaded_scheduler(self):
# This test will create 4 routers each with its own gateway.
# Using the least loaded policy for scheduling gateway ports, we
@ -241,26 +232,17 @@ class TestRouter(base.TestOVNFunctionalBase):
# At this point we expect two gateways to be present in chassis1
# and two in chassis2. If schema supports L3 HA, we expect each
# chassis to host 2 priority 2 gateways and 2 priority 1 ones.
if self._l3_ha_supported():
# Each chassis contains a dict of (priority, # of ports hosted).
# {1: 2, 2: 2} means that this chassis hosts 2 ports of prio 1
# and two ports of prio 2.
expected = {self.chassis1: {1: 2, 2: 2},
self.chassis2: {1: 2, 2: 2}}
else:
# For non L3 HA, each chassis should contain two gateway ports.
expected = {self.chassis1: 2,
self.chassis2: 2}
# Each chassis contains a dict of (priority, # of ports hosted).
# {1: 2, 2: 2} means that this chassis hosts 2 ports of prio 1
# and two ports of prio 2.
expected = {self.chassis1: {1: 2, 2: 2},
self.chassis2: {1: 2, 2: 2}}
sched_info = {}
for row in self.nb_api.tables[
'Logical_Router_Port'].rows.values():
if self._l3_ha_supported():
for gwc in row.gateway_chassis:
chassis = sched_info.setdefault(gwc.chassis_name, {})
chassis[gwc.priority] = chassis.get(gwc.priority, 0) + 1
else:
rc = row.options.get(ovn_const.OVN_GATEWAY_CHASSIS_KEY)
sched_info[rc] = sched_info.get(rc, 0) + 1
for gwc in row.gateway_chassis:
chassis = sched_info.setdefault(gwc.chassis_name, {})
chassis[gwc.priority] = chassis.get(gwc.priority, 0) + 1
self.assertEqual(expected, sched_info)
def _get_gw_port(self, router_id):
@ -531,8 +513,6 @@ class TestRouter(base.TestOVNFunctionalBase):
chassis[gwc.priority] = chassis.get(gwc.priority, 0) + 1
return sched_info
if not self._l3_ha_supported():
self.skipTest('L3 HA not supported')
ovn_client = self.l3_plugin._ovn_client
chassis4 = self.add_fake_chassis(
'ovs-host4', physical_nets=['physnet4'], other_config={