diff --git a/neutron/agent/ovn/metadata/agent.py b/neutron/agent/ovn/metadata/agent.py index b59fbbd4cd8..0cd9ecb8681 100644 --- a/neutron/agent/ovn/metadata/agent.py +++ b/neutron/agent/ovn/metadata/agent.py @@ -227,8 +227,10 @@ class SbGlobalUpdateEvent(row_event.RowEvent): def run(self, event, row, old): def _update_chassis(self, row): + table = ('Chassis_Private' if self.agent.has_chassis_private + else 'Chassis') self.agent.sb_idl.db_set( - 'Chassis_Private', self.agent.chassis, ('external_ids', { + table, self.agent.chassis, ('external_ids', { ovn_const.OVN_AGENT_METADATA_SB_CFG_KEY: str(row.nb_cfg)})).execute() @@ -291,17 +293,27 @@ class MetadataAgent(object): self._load_config() tables = ('Encap', 'Port_Binding', 'Datapath_Binding', 'SB_Global', - 'Chassis', 'Chassis_Private') + 'Chassis') events = (PortBindingChassisCreatedEvent(self), PortBindingChassisDeletedEvent(self), SbGlobalUpdateEvent(self), - PortBindingMetaPortUpdatedEvent(self), - ChassisPrivateCreateEvent(self), - ) + PortBindingMetaPortUpdatedEvent(self)) + # TODO(lucasagomes): Remove this in the future. Try to register + # the Chassis_Private table, if not present, fallback to the normal + # Chassis table. + # Open the connection to OVN SB database. + self.has_chassis_private = False self._post_fork_event.clear() - self.sb_idl = ovsdb.MetadataAgentOvnSbIdl( - chassis=self.chassis, tables=tables, events=events).start() + try: + self.sb_idl = ovsdb.MetadataAgentOvnSbIdl( + chassis=self.chassis, tables=tables + ('Chassis_Private', ), + events=events + (ChassisPrivateCreateEvent(self), )).start() + self.has_chassis_private = True + except AssertionError: + self.sb_idl = ovsdb.MetadataAgentOvnSbIdl( + chassis=self.chassis, tables=tables, + events=events + (ChassisCreateEvent(self), )).start() # Now IDL connections can be safely used. self._post_fork_event.set() @@ -323,10 +335,11 @@ class MetadataAgent(object): def register_metadata_agent(self): # NOTE(lucasagomes): db_add() will not overwrite the UUID if # it's already set. + table = ('Chassis_Private' if self.has_chassis_private else 'Chassis') # Generate unique, but consistent metadata id for chassis name agent_id = uuid.uuid5(self.chassis_id, 'metadata_agent') ext_ids = {ovn_const.OVN_AGENT_METADATA_ID_KEY: str(agent_id)} - self.sb_idl.db_add('Chassis_Private', self.chassis, 'external_ids', + self.sb_idl.db_add(table, self.chassis, 'external_ids', ext_ids).execute(check_error=True) def _get_own_chassis_name(self): diff --git a/neutron/cmd/sanity/checks.py b/neutron/cmd/sanity/checks.py index 10dbf3c2cc5..329e99463a9 100644 --- a/neutron/cmd/sanity/checks.py +++ b/neutron/cmd/sanity/checks.py @@ -54,7 +54,6 @@ OVN_NB_DB_SCHEMA_PORT_GROUP = '5.11.0' OVN_NB_DB_SCHEMA_STATELESS_NAT = '5.17.0' OVN_SB_DB_SCHEMA_VIRTUAL_PORT = '2.5.0' OVN_LOCALNET_LEARN_FDB = '22.09.0' -OVN_SB_DB_SCHEMA_CHASSIS_PRIVATE = '2.9.0' class OVNCheckType(enum.Enum): @@ -680,17 +679,3 @@ def ovn_localnet_learn_fdb_support(): 'Exception: %s', e) return False return True - - -def ovn_sb_db_schema_chassis_private_supported(): - try: - ver = _get_ovn_version(OVNCheckType.sb_db_schema) - minver = versionutils.convert_version_to_tuple( - OVN_SB_DB_SCHEMA_CHASSIS_PRIVATE) - 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 diff --git a/neutron/cmd/sanity_check.py b/neutron/cmd/sanity_check.py index 70735bc6d96..8bd4318305b 100644 --- a/neutron/cmd/sanity_check.py +++ b/neutron/cmd/sanity_check.py @@ -352,13 +352,6 @@ def check_ovn_localnet_learn_fdb_support(): if not result: LOG.warning('OVN does not support localnet_learn_fdb option. ' 'This support was added in OVN 22.09.') - - -def check_ovn_sb_db_schema_chassis_private(): - result = checks.ovn_sb_db_schema_chassis_private_supported() - if not result: - LOG.warning('OVN SB DB schema does not support chassis private. This ' - 'support was added in DB schema version 2.9.0.') return result @@ -450,10 +443,6 @@ OPTS = [ check_ovn_localnet_learn_fdb_support, help=_('Check OVN supports localnet_learn_fdb option'), default=False), - BoolOptCallback('ovn_sb_db_schema_chassis_private_support', - check_ovn_sb_db_schema_virtual_port, - help=_('Check OVN SB DB schema support chassis private'), - default=False), ] diff --git a/neutron/plugins/ml2/drivers/ovn/agent/neutron_agent.py b/neutron/plugins/ml2/drivers/ovn/agent/neutron_agent.py index 4e58154f7fe..222c9e9cce8 100644 --- a/neutron/plugins/ml2/drivers/ovn/agent/neutron_agent.py +++ b/neutron/plugins/ml2/drivers/ovn/agent/neutron_agent.py @@ -63,22 +63,19 @@ class NeutronAgent(abc.ABC): self.set_down = False @staticmethod - def _get_chassis(chassis_or_chassis_private): - """Return the chassis register - - The input could be the chassis register itself or the chassis private. - """ + def chassis_from_private(chassis_private): try: - return chassis_or_chassis_private.chassis[0] + return chassis_private.chassis[0] except AttributeError: - return chassis_or_chassis_private + # No Chassis_Private support, just use Chassis + return chassis_private except IndexError: # Chassis register has been deleted but not Chassis_Private. return DeletedChassis @property def chassis(self): - return self._get_chassis(self.chassis_private) + return self.chassis_from_private(self.chassis_private) def as_dict(self): return { @@ -146,7 +143,7 @@ class ControllerAgent(NeutronAgent): @staticmethod # it is by default, but this makes pep8 happy def __new__(cls, chassis_private, driver): - _chassis = cls._get_chassis(chassis_private) + _chassis = cls.chassis_from_private(chassis_private) other_config = ovn_utils.get_ovn_chassis_other_config(_chassis) if 'enable-chassis-as-gw' in other_config.get('ovn-cms-options', []): cls = ControllerGatewayAgent @@ -171,7 +168,7 @@ class ControllerAgent(NeutronAgent): def update(self, chassis_private, clear_down=False): super().update(chassis_private, clear_down) - _chassis = self._get_chassis(chassis_private) + _chassis = self.chassis_from_private(chassis_private) other_config = ovn_utils.get_ovn_chassis_other_config(_chassis) if 'enable-chassis-as-gw' in other_config.get('ovn-cms-options', []): self.__class__ = ControllerGatewayAgent @@ -182,7 +179,7 @@ class ControllerGatewayAgent(ControllerAgent): def update(self, chassis_private, clear_down=False): super().update(chassis_private, clear_down) - _chassis = self._get_chassis(chassis_private) + _chassis = self.chassis_from_private(chassis_private) other_config = ovn_utils.get_ovn_chassis_other_config(_chassis) if ('enable-chassis-as-gw' not in other_config.get('ovn-cms-options', [])): diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py index a9a2353ce59..00178067daf 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py @@ -137,7 +137,10 @@ class OVNMechanismDriver(api.MechanismDriver): OVN_MIN_GENEVE_MAX_HEADER_SIZE) raise SystemExit(1) self._setup_vif_port_bindings() - self.agent_chassis_table = 'Chassis_Private' + if impl_idl_ovn.OvsdbSbOvnIdl.schema_has_table('Chassis_Private'): + self.agent_chassis_table = 'Chassis_Private' + else: + self.agent_chassis_table = 'Chassis' self.subscribe() self.qos_driver = qos_driver.OVNQosDriver.create(self) self.trunk_driver = trunk_driver.OVNTrunkDriver.create(self) diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py index fc4b9fa80c9..9b0ba129aa9 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py @@ -358,7 +358,8 @@ class ChassisAgentTypeChangeEvent(ChassisEvent): 'external_ids') if not getattr(old, other_config, False): return False - new_other_config = utils.get_ovn_chassis_other_config(row) + chassis = n_agent.NeutronAgent.chassis_from_private(row) + new_other_config = utils.get_ovn_chassis_other_config(chassis) old_other_config = utils.get_ovn_chassis_other_config(old) agent_type_change = new_other_config.get('ovn-cms-options', []) != ( old_other_config.get('ovn-cms-options', [])) @@ -656,7 +657,6 @@ class BaseOvnIdl(Ml2OvnIdlBase): class BaseOvnSbIdl(Ml2OvnIdlBase): @classmethod def from_server(cls, connection_string, helper): - helper.register_table('Chassis_Private') helper.register_table('Chassis') helper.register_table('Encap') helper.register_table('Port_Binding') @@ -713,6 +713,13 @@ class OvnIdlDistributedLock(BaseOvnIdl): self.update_tables(tables, row.schema[0]) + if self.driver.agent_chassis_table == 'Chassis_Private': + if 'Chassis_Private' not in self.tables: + self.driver.agent_chassis_table = 'Chassis' + else: + if 'Chassis_Private' in self.tables: + self.driver.agent_chassis_table = 'Chassis_Private' + def notify(self, event, row, updates=None): try: self.handle_db_schema_changes(event, row) @@ -813,9 +820,10 @@ class OvnSbIdl(OvnIdlDistributedLock): @classmethod def from_server(cls, connection_string, helper, driver): + if 'Chassis_Private' in helper.schema_json['tables']: + helper.register_table('Chassis_Private') if 'FDB' in helper.schema_json['tables']: helper.register_table('FDB') - helper.register_table('Chassis_Private') helper.register_table('Chassis') helper.register_table('Encap') helper.register_table('Port_Binding') diff --git a/neutron/tests/functional/agent/ovn/metadata/test_metadata_agent.py b/neutron/tests/functional/agent/ovn/metadata/test_metadata_agent.py index 8463b5f364b..d0d4aebac3a 100644 --- a/neutron/tests/functional/agent/ovn/metadata/test_metadata_agent.py +++ b/neutron/tests/functional/agent/ovn/metadata/test_metadata_agent.py @@ -85,7 +85,9 @@ class TestMetadataAgent(base.TestOVNFunctionalBase): @property def agent_chassis_table(self): - return 'Chassis_Private' + if self.agent.has_chassis_private: + return 'Chassis_Private' + return 'Chassis' def _start_metadata_agent(self): conf = self.useFixture(fixture_config.Config()).conf diff --git a/neutron/tests/functional/base.py b/neutron/tests/functional/base.py index 54d37b2e8a0..8ef793989eb 100644 --- a/neutron/tests/functional/base.py +++ b/neutron/tests/functional/base.py @@ -423,15 +423,17 @@ class TestOVNFunctionalBase(test_plugin.Ml2PluginV2TestCase, name, ['geneve'], '172.24.4.%d' % self._counter, external_ids=external_ids, hostname=host, other_config=other_config).execute(check_error=True) - nb_cfg_timestamp = timeutils.utcnow_ts() * 1000 - self.sb_api.db_create( - 'Chassis_Private', name=name, external_ids=external_ids, - chassis=chassis.uuid, nb_cfg_timestamp=nb_cfg_timestamp - ).execute(check_error=True) + if self.sb_api.is_table_present('Chassis_Private'): + nb_cfg_timestamp = timeutils.utcnow_ts() * 1000 + self.sb_api.db_create( + 'Chassis_Private', name=name, external_ids=external_ids, + chassis=chassis.uuid, nb_cfg_timestamp=nb_cfg_timestamp + ).execute(check_error=True) return name def del_fake_chassis(self, chassis, if_exists=True): self.sb_api.chassis_del( chassis, if_exists=if_exists).execute(check_error=True) - self.sb_api.db_destroy( - 'Chassis_Private', chassis).execute(check_error=True) + if self.sb_api.is_table_present('Chassis_Private'): + self.sb_api.db_destroy( + 'Chassis_Private', chassis).execute(check_error=True) diff --git a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py index d52259457b0..1eea038c018 100644 --- a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py +++ b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py @@ -470,6 +470,8 @@ class TestAgentMonitor(base.TestOVNFunctionalBase): int(chassis_ts / 1000), datetime.timezone.utc) return agent.updated_at == updated_at + if not self.sb_api.is_table_present('Chassis_Private'): + self.skipTest('Ovn sb not support Chassis_Private') timestamp = timeutils.utcnow_ts() nb_cfg_timestamp = timestamp * 1000 self.sb_api.db_set('Chassis_Private', self.chassis_name, ( @@ -502,6 +504,9 @@ class TestAgentMonitor(base.TestOVNFunctionalBase): agent = neutron_agent.AgentCache()[self.chassis_name] return agent.updated_at != 0 + if not self.sb_api.is_table_present('Chassis_Private'): + self.skipTest('Ovn sb not support Chassis_Private') + # Set nb_cfg to some realistic value, so that the alive check can # actually work self.nb_api.db_set( diff --git a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py index 1b937e4f18c..e1abd67c8e9 100644 --- a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py +++ b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py @@ -1179,11 +1179,15 @@ class TestAgentApi(base.TestOVNFunctionalBase): agent_id = self.agent_types[ovn_const.OVN_CONTROLLER_AGENT] agent = self.plugin.get_agent(self.context, agent_id) heartbeat_timestamp = agent['heartbeat_timestamp'] - chassis_ts = self.sb_api.db_get( - 'Chassis_Private', self.chassis, 'nb_cfg_timestamp' - ).execute(check_error=True) - updated_at = datetime.datetime.fromtimestamp(int(chassis_ts / 1000)) - self.assertEqual(updated_at, heartbeat_timestamp) + if self.sb_api.is_table_present('Chassis_Private'): + chassis_ts = self.sb_api.db_get( + 'Chassis_Private', self.chassis, 'nb_cfg_timestamp' + ).execute(check_error=True) + updated_at = datetime.datetime.fromtimestamp( + int(chassis_ts / 1000)) + # if table Chassis_Private present, agent.updated_at is + # Chassis_Private.nb_cfg_timestamp + self.assertEqual(updated_at, heartbeat_timestamp) time.sleep(1) # if chassis is not updated, agent's heartbeat_timestamp shouldn't # be updated. diff --git a/neutron/tests/unit/plugins/ml2/drivers/ovn/agent/test_neutron_agent.py b/neutron/tests/unit/plugins/ml2/drivers/ovn/agent/test_neutron_agent.py index b3c8d73b82e..9f92a65ff07 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/ovn/agent/test_neutron_agent.py +++ b/neutron/tests/unit/plugins/ml2/drivers/ovn/agent/test_neutron_agent.py @@ -16,7 +16,6 @@ import datetime from unittest import mock import eventlet -from oslo_utils import timeutils from neutron.common.ovn import constants as ovn_const from neutron.plugins.ml2.drivers.ovn.agent import neutron_agent @@ -32,13 +31,8 @@ class AgentCacheTestCase(base.BaseTestCase): self.addCleanup(self._clean_agent_cache) self.names_ref = [] for i in range(10): # Add 10 agents. - chassis = fakes.FakeOvsdbRow.create_one_ovsdb_row( - attrs={'other_config': {}}) chassis_private = fakes.FakeOvsdbRow.create_one_ovsdb_row( - attrs={'name': 'chassis' + str(i), - 'other_config': {}, - 'chassis': [chassis], - 'nb_cfg_timestamp': timeutils.utcnow_ts() * 1000}) + attrs={'name': 'chassis' + str(i), 'other_config': {}}) self.agent_cache.update(ovn_const.OVN_CONTROLLER_AGENT, chassis_private) self.names_ref.append('chassis' + str(i)) @@ -55,12 +49,8 @@ class AgentCacheTestCase(base.BaseTestCase): def _add_and_delete_agents(self): del self.agent_cache['chassis8'] - chassis = fakes.FakeOvsdbRow.create_one_ovsdb_row( - attrs={'other_config': {}}) chassis_private = fakes.FakeOvsdbRow.create_one_ovsdb_row( - attrs={'name': 'chassis10', - 'chassis': [chassis], - 'nb_cfg_timestamp': timeutils.utcnow_ts() * 1000}) + attrs={'name': 'chassis10'}) self.agent_cache.update(ovn_const.OVN_CONTROLLER_AGENT, chassis_private) diff --git a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/schemas/ovn-nb.ovsschema b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/schemas/ovn-nb.ovsschema index 174364c8b14..a06972aa061 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/schemas/ovn-nb.ovsschema +++ b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/schemas/ovn-nb.ovsschema @@ -1,17 +1,14 @@ { "name": "OVN_Northbound", - "version": "6.3.0", - "cksum": "4042813038 31869", + "version": "5.23.0", + "cksum": "111023208 25806", "tables": { "NB_Global": { "columns": { "name": {"type": "string"}, "nb_cfg": {"type": {"key": "integer"}}, - "nb_cfg_timestamp": {"type": {"key": "integer"}}, "sb_cfg": {"type": {"key": "integer"}}, - "sb_cfg_timestamp": {"type": {"key": "integer"}}, "hv_cfg": {"type": {"key": "integer"}}, - "hv_cfg_timestamp": {"type": {"key": "integer"}}, "external_ids": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}, @@ -30,19 +27,6 @@ "ipsec": {"type": "boolean"}}, "maxRows": 1, "isRoot": true}, - "Copp": { - "columns": { - "name": {"type": "string"}, - "meters": { - "type": {"key": "string", - "value": "string", - "min": 0, - "max": "unlimited"}}, - "external_ids": { - "type": {"key": "string", "value": "string", - "min": 0, "max": "unlimited"}}}, - "indexes": [["name"]], - "isRoot": true}, "Logical_Switch": { "columns": { "name": {"type": "string"}, @@ -66,19 +50,11 @@ "refType": "weak"}, "min": 0, "max": "unlimited"}}, - "load_balancer_group": { - "type": {"key": {"type": "uuid", - "refTable": "Load_Balancer_Group"}, - "min": 0, - "max": "unlimited"}}, "dns_records": {"type": {"key": {"type": "uuid", "refTable": "DNS", "refType": "weak"}, "min": 0, "max": "unlimited"}}, - "copp": {"type": {"key": {"type": "uuid", "refTable": "Copp", - "refType": "weak"}, - "min": 0, "max": 1}}, "other_config": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}, @@ -209,25 +185,10 @@ ["eth_src", "eth_dst", "ip_src", "ip_dst", "tp_src", "tp_dst"]]}, "min": 0, "max": "unlimited"}}, - "options": { - "type": {"key": "string", - "value": "string", - "min": 0, - "max": "unlimited"}}, "external_ids": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}}, "isRoot": true}, - "Load_Balancer_Group": { - "columns": { - "name": {"type": "string"}, - "load_balancer": {"type": {"key": {"type": "uuid", - "refTable": "Load_Balancer", - "refType": "weak"}, - "min": 0, - "max": "unlimited"}}}, - "indexes": [["name"]], - "isRoot": true}, "Load_Balancer_Health_Check": { "columns": { "vip": {"type": "string"}, @@ -252,10 +213,7 @@ "enum": ["set", ["from-lport", "to-lport"]]}}}, "match": {"type": "string"}, "action": {"type": {"key": {"type": "string", - "enum": ["set", - ["allow", "allow-related", - "allow-stateless", "drop", - "reject"]]}}}, + "enum": ["set", ["allow", "allow-related", "drop", "reject"]]}}}, "log": {"type": "boolean"}, "severity": {"type": {"key": {"type": "string", "enum": ["set", @@ -264,14 +222,6 @@ "debug"]]}, "min": 0, "max": 1}}, "meter": {"type": {"key": "string", "min": 0, "max": 1}}, - "label": {"type": {"key": {"type": "integer", - "minInteger": 0, - "maxInteger": 4294967295}}}, - "options": { - "type": {"key": "string", - "value": "string", - "min": 0, - "max": "unlimited"}}, "external_ids": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}}, @@ -311,7 +261,6 @@ "refType": "strong"}, "min": 1, "max": "unlimited"}}, - "fair": {"type": {"key": "boolean", "min": 0, "max": 1}}, "external_ids": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}}, @@ -361,14 +310,6 @@ "refType": "weak"}, "min": 0, "max": "unlimited"}}, - "load_balancer_group": { - "type": {"key": {"type": "uuid", - "refTable": "Load_Balancer_Group"}, - "min": 0, - "max": "unlimited"}}, - "copp": {"type": {"key": {"type": "uuid", "refTable": "Copp", - "refType": "weak"}, - "min": 0, "max": 1}}, "options": { "type": {"key": "string", "value": "string", @@ -417,7 +358,6 @@ "isRoot": false}, "Logical_Router_Static_Route": { "columns": { - "route_table": {"type": "string"}, "ip_prefix": {"type": "string"}, "policy": {"type": {"key": {"type": "string", "enum": ["set", ["src-ip", @@ -425,13 +365,6 @@ "min": 0, "max": 1}}, "nexthop": {"type": "string"}, "output_port": {"type": {"key": "string", "min": 0, "max": 1}}, - "bfd": {"type": {"key": {"type": "uuid", "refTable": "BFD", - "refType": "weak"}, - "min": 0, - "max": 1}}, - "options": { - "type": {"key": "string", "value": "string", - "min": 0, "max": "unlimited"}}, "external_ids": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}}, @@ -446,11 +379,6 @@ "key": {"type": "string", "enum": ["set", ["allow", "drop", "reroute"]]}}}, "nexthop": {"type": {"key": "string", "min": 0, "max": 1}}, - "nexthops": {"type": { - "key": "string", "min": 0, "max": "unlimited"}}, - "options": { - "type": {"key": "string", "value": "string", - "min": 0, "max": "unlimited"}}, "external_ids": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}}, @@ -469,22 +397,6 @@ "snat", "dnat_and_snat" ]]}}}, - "allowed_ext_ips": {"type": { - "key": {"type": "uuid", "refTable": "Address_Set", - "refType": "strong"}, - "min": 0, - "max": 1}}, - "exempted_ext_ips": {"type": { - "key": {"type": "uuid", "refTable": "Address_Set", - "refType": "strong"}, - "min": 0, - "max": 1}}, - "gateway_port": { - "type": {"key": {"type": "uuid", - "refTable": "Logical_Router_Port", - "refType": "weak"}, - "min": 0, - "max": 1}}, "options": {"type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}, "external_ids": { @@ -587,39 +499,5 @@ "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}}, "indexes": [["name"]], - "isRoot": true}, - "BFD": { - "columns": { - "logical_port": {"type": "string"}, - "dst_ip": {"type": "string"}, - "min_tx": {"type": {"key": {"type": "integer", - "minInteger": 1}, - "min": 0, "max": 1}}, - "min_rx": {"type": {"key": {"type": "integer"}, - "min": 0, "max": 1}}, - "detect_mult": {"type": {"key": {"type": "integer", - "minInteger": 1}, - "min": 0, "max": 1}}, - "status": { - "type": {"key": {"type": "string", - "enum": ["set", ["down", "init", "up", - "admin_down"]]}, - "min": 0, "max": 1}}, - "external_ids": { - "type": {"key": "string", "value": "string", - "min": 0, "max": "unlimited"}}, - "options": { - "type": {"key": "string", "value": "string", - "min": 0, "max": "unlimited"}}}, - "indexes": [["logical_port", "dst_ip"]], - "isRoot": true}, - "Static_MAC_Binding": { - "columns": { - "logical_port": {"type": "string"}, - "ip": {"type": "string"}, - "mac": {"type": "string"}, - "override_dynamic_mac": {"type": "boolean"}}, - "indexes": [["logical_port", "ip"]], - "isRoot": true} + "isRoot": true}} } -} diff --git a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/schemas/ovn-sb.ovsschema b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/schemas/ovn-sb.ovsschema index 576ebbdeb07..d89f8dbbbde 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/schemas/ovn-sb.ovsschema +++ b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/schemas/ovn-sb.ovsschema @@ -1,7 +1,7 @@ { "name": "OVN_Southbound", - "version": "20.25.0", - "cksum": "53184112 28845", + "version": "2.7.0", + "cksum": "4286723485 21693", "tables": { "SB_Global": { "columns": { @@ -38,28 +38,11 @@ "external_ids": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}, - "other_config": { - "type": {"key": "string", "value": "string", - "min": 0, "max": "unlimited"}}, "transport_zones" : {"type": {"key": "string", "min": 0, "max": "unlimited"}}}, "isRoot": true, "indexes": [["name"]]}, - "Chassis_Private": { - "columns": { - "name": {"type": "string"}, - "chassis": {"type": {"key": {"type": "uuid", - "refTable": "Chassis", - "refType": "weak"}, - "min": 0, "max": 1}}, - "nb_cfg": {"type": {"key": "integer"}}, - "nb_cfg_timestamp": {"type": {"key": "integer"}}, - "external_ids": { - "type": {"key": "string", "value": "string", - "min": 0, "max": "unlimited"}}}, - "isRoot": true, - "indexes": [["name"]]}, "Encap": { "columns": { "type": {"type": {"key": { @@ -90,42 +73,23 @@ "isRoot": true}, "Logical_Flow": { "columns": { - "logical_datapath": - {"type": {"key": {"type": "uuid", - "refTable": "Datapath_Binding"}, - "min": 0, "max": 1}}, - "logical_dp_group": - {"type": {"key": {"type": "uuid", - "refTable": "Logical_DP_Group"}, - "min": 0, "max": 1}}, + "logical_datapath": {"type": {"key": {"type": "uuid", + "refTable": "Datapath_Binding"}}}, "pipeline": {"type": {"key": {"type": "string", "enum": ["set", ["ingress", "egress"]]}}}, "table_id": {"type": {"key": {"type": "integer", "minInteger": 0, - "maxInteger": 32}}}, + "maxInteger": 23}}}, "priority": {"type": {"key": {"type": "integer", "minInteger": 0, "maxInteger": 65535}}}, "match": {"type": "string"}, "actions": {"type": "string"}, - "tags": { - "type": {"key": "string", "value": "string", - "min": 0, "max": "unlimited"}}, - "controller_meter": {"type": {"key": {"type": "string"}, - "min": 0, "max": 1}}, "external_ids": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}}, "isRoot": true}, - "Logical_DP_Group": { - "columns": { - "datapaths": - {"type": {"key": {"type": "uuid", - "refTable": "Datapath_Binding", - "refType": "weak"}, - "min": 0, "max": "unlimited"}}}, - "isRoot": false}, "Multicast_Group": { "columns": { "datapath": {"type": {"key": {"type": "uuid", @@ -138,7 +102,7 @@ "ports": {"type": {"key": {"type": "uuid", "refTable": "Port_Binding", "refType": "weak"}, - "min": 0, "max": "unlimited"}}}, + "min": 1, "max": "unlimited"}}}, "indexes": [["datapath", "tunnel_key"], ["datapath", "name"]], "isRoot": true}, @@ -171,9 +135,6 @@ "type": {"key": {"type": "integer", "minInteger": 1, "maxInteger": 16777215}}}, - "load_balancers": {"type": {"key": {"type": "uuid"}, - "min": 0, - "max": "unlimited"}}, "external_ids": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}}, @@ -218,41 +179,20 @@ "refTable": "Chassis", "refType": "weak"}, "min": 0, "max": 1}}, - "additional_chassis": {"type": {"key": {"type": "uuid", - "refTable": "Chassis", - "refType": "weak"}, - "min": 0, "max": "unlimited"}}, "encap": {"type": {"key": {"type": "uuid", "refTable": "Encap", "refType": "weak"}, "min": 0, "max": 1}}, - "additional_encap": {"type": {"key": {"type": "uuid", - "refTable": "Encap", - "refType": "weak"}, - "min": 0, "max": "unlimited"}}, "mac": {"type": {"key": "string", "min": 0, "max": "unlimited"}}, - "port_security": {"type": {"key": "string", - "min": 0, - "max": "unlimited"}}, "nat_addresses": {"type": {"key": "string", "min": 0, "max": "unlimited"}}, - "up": {"type": {"key": "boolean", "min": 0, "max": 1}}, "external_ids": {"type": {"key": "string", "value": "string", "min": 0, - "max": "unlimited"}}, - "requested_chassis": {"type": {"key": {"type": "uuid", - "refTable": "Chassis", - "refType": "weak"}, - "min": 0, "max": 1}}, - "requested_additional_chassis": { - "type": {"key": {"type": "uuid", - "refTable": "Chassis", - "refType": "weak"}, - "min": 0, "max": "unlimited"}}}, + "max": "unlimited"}}}, "indexes": [["datapath", "tunnel_key"], ["logical_port"]], "isRoot": true}, "MAC_Binding": { @@ -260,7 +200,6 @@ "logical_port": {"type": "string"}, "ip": {"type": "string"}, "mac": {"type": "string"}, - "timestamp": {"type": {"key": "integer"}}, "datapath": {"type": {"key": {"type": "uuid", "refTable": "Datapath_Binding"}}}}, "indexes": [["logical_port", "ip"]], @@ -275,8 +214,7 @@ "type": {"key": { "type": "string", "enum": ["set", ["bool", "uint8", "uint16", "uint32", - "ipv4", "static_routes", "str", - "host_id", "domains"]]}}}}, + "ipv4", "static_routes", "str"]]}}}}, "isRoot": true}, "DHCPv6_Options": { "columns": { @@ -476,7 +414,7 @@ "min": 0, "max": 1}}, "port": {"type": {"key": {"type": "integer", "minInteger": 0, - "maxInteger": 65535}}}, + "maxInteger": 32767}}}, "logical_port": {"type": "string"}, "src_mac": {"type": "string"}, "src_ip": {"type": "string"}, @@ -491,80 +429,6 @@ "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}}, "indexes": [["logical_port", "ip", "port", "protocol"]], - "isRoot": true}, - "Load_Balancer": { - "columns": { - "name": {"type": "string"}, - "vips": { - "type": {"key": "string", "value": "string", - "min": 0, "max": "unlimited"}}, - "protocol": { - "type": {"key": {"type": "string", - "enum": ["set", ["tcp", "udp", "sctp"]]}, - "min": 0, "max": 1}}, - "datapaths": { - "type": {"key": {"type": "uuid", - "refTable": "Datapath_Binding"}, - "min": 0, "max": "unlimited"}}, - "datapath_group": - {"type": {"key": {"type": "uuid", - "refTable": "Logical_DP_Group"}, - "min": 0, "max": 1}}, - "options": { - "type": {"key": "string", - "value": "string", - "min": 0, - "max": "unlimited"}}, - "external_ids": { - "type": {"key": "string", "value": "string", - "min": 0, "max": "unlimited"}}}, - "isRoot": true}, - "BFD": { - "columns": { - "src_port": {"type": {"key": {"type": "integer", - "minInteger": 49152, - "maxInteger": 65535}}}, - "disc": {"type": {"key": {"type": "integer"}}}, - "logical_port": {"type": "string"}, - "dst_ip": {"type": "string"}, - "min_tx": {"type": {"key": {"type": "integer"}}}, - "min_rx": {"type": {"key": {"type": "integer"}}}, - "detect_mult": {"type": {"key": {"type": "integer"}}}, - "status": { - "type": {"key": {"type": "string", - "enum": ["set", ["down", "init", "up", - "admin_down"]]}}}, - "external_ids": { - "type": {"key": "string", "value": "string", - "min": 0, "max": "unlimited"}}, - "options": { - "type": {"key": "string", "value": "string", - "min": 0, "max": "unlimited"}}}, - "indexes": [["logical_port", "dst_ip", "src_port", "disc"]], - "isRoot": true}, - "FDB": { - "columns": { - "mac": {"type": "string"}, - "dp_key": { - "type": {"key": {"type": "integer", - "minInteger": 1, - "maxInteger": 16777215}}}, - "port_key": { - "type": {"key": {"type": "integer", - "minInteger": 1, - "maxInteger": 16777215}}}}, - "indexes": [["mac", "dp_key"]], - "isRoot": true}, - "Static_MAC_Binding": { - "columns": { - "logical_port": {"type": "string"}, - "ip": {"type": "string"}, - "mac": {"type": "string"}, - "override_dynamic_mac": {"type": "boolean"}, - "datapath": {"type": { - "key": {"type": "uuid", - "refTable": "Datapath_Binding"}}}}, - "indexes": [["logical_port", "ip"]], "isRoot": true} } } diff --git a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py index 443a19f1ab1..9523be67b03 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py +++ b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py @@ -302,20 +302,45 @@ class TestOvnIdlDistributedLock(base.BaseTestCase): self.assertFalse(self.mock_update_tables.called) - def _test_handle_db_schema(self, agent_table): + def _test_handle_db_schema(self, agent_table, chassis_private_present): database_table_row = self._create_fake_row('Database') self.idl._tables_to_register[database_table_row.name] = 'foo' self.fake_driver.agent_chassis_table = agent_table - self.idl.tables['Chassis_Private'] = 'foo' + if chassis_private_present: + self.idl.tables['Chassis_Private'] = 'foo' + else: + try: + del self.idl.tables['Chassis_Private'] + except KeyError: + pass + self.idl.handle_db_schema_changes( ovsdb_monitor.BaseEvent.ROW_CREATE, database_table_row) + def test_handle_db_schema_changes_old_schema_to_old_schema(self): + """Agents use Chassis and should keep using Chassis table""" + self._test_handle_db_schema('Chassis', chassis_private_present=False) + self.assertEqual('Chassis', self.fake_driver.agent_chassis_table) + + def test_handle_db_schema_changes_old_schema_to_new_schema(self): + """Agents use Chassis and should start using Chassis_Private table""" + self._test_handle_db_schema('Chassis', chassis_private_present=True) + self.assertEqual('Chassis_Private', + self.fake_driver.agent_chassis_table) + + def test_handle_db_schema_changes_new_schema_to_old_schema(self): + """Agents use Chassis_Private and should start using Chassis table""" + self._test_handle_db_schema('Chassis_Private', + chassis_private_present=False) + self.assertEqual('Chassis', self.fake_driver.agent_chassis_table) + def test_handle_db_schema_changes_new_schema_to_new_schema(self): """Agents use Chassis_Private and should keep using Chassis_Private table. """ - self._test_handle_db_schema('Chassis_Private') + self._test_handle_db_schema('Chassis_Private', + chassis_private_present=True) self.assertEqual('Chassis_Private', self.fake_driver.agent_chassis_table) diff --git a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py index 8a8f59b1f0d..9ebd918ca95 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py +++ b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py @@ -105,7 +105,6 @@ class MechDriverSetupBase(abc.ABC): chassis_private.nb_cfg = nb_cfg chassis_private.uuid = uuid.uuid4() chassis_private.name = name if name else str(uuid.uuid4()) - chassis_private.nb_cfg_timestamp = timeutils.utcnow_ts() * 1000 return chassis_private def _add_chassis_agent(self, nb_cfg, agent_type, chassis_private=None): diff --git a/releasenotes/notes/ovn-support-chassis_private-35192565e9ee2a00.yaml b/releasenotes/notes/ovn-support-chassis_private-35192565e9ee2a00.yaml deleted file mode 100644 index a933db5f513..00000000000 --- a/releasenotes/notes/ovn-support-chassis_private-35192565e9ee2a00.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -features: - - | - Removed support for OVN versions under 20.09. The "Chassis_Private" OVN - Southbound table is expected in the database definition.