Merge "[OVN] OVN agents should clean up "Chassis_Private" tags"
This commit is contained in:
@@ -159,6 +159,24 @@ class OVNNeutronAgent(service.Service):
|
||||
self.sb_idl.db_add('Chassis_Private', self.chassis, 'external_ids',
|
||||
ext_ids).execute(check_error=True)
|
||||
|
||||
def _cleanup_previous_tags(self):
|
||||
"""Remove any existing tag related to the OVN Metadata agent
|
||||
|
||||
The OVN Metadata agent is deprecated and marked for removal in 2026.2.
|
||||
This code should stay during the following SLURP release (2027.1) and
|
||||
be removed in the next release (2027.2).
|
||||
|
||||
While both agents can provide the same functionality (OVN Metadata
|
||||
agent and OVN agent with the metadata extension), it is needed to
|
||||
provide a cleanup method for any leftover tag from the other agent.
|
||||
"""
|
||||
metadata_keys = (ovn_const.OVN_AGENT_METADATA_SB_CFG_KEY,
|
||||
ovn_const.OVN_AGENT_METADATA_DESC_KEY,
|
||||
ovn_const.OVN_AGENT_METADATA_ID_KEY)
|
||||
self.sb_idl.db_remove(
|
||||
'Chassis_Private', self.chassis, 'external_ids',
|
||||
*metadata_keys, if_exists=True).execute(check_error=True)
|
||||
|
||||
def update_neutron_sb_cfg_key(self):
|
||||
nb_cfg = self.sb_idl.db_get('Chassis_Private',
|
||||
self.chassis, 'nb_cfg').execute()
|
||||
@@ -176,6 +194,7 @@ class OVNNeutronAgent(service.Service):
|
||||
self.ext_manager_api.nb_idl = self._load_nb_idl()
|
||||
self.ext_manager.start()
|
||||
|
||||
self._cleanup_previous_tags()
|
||||
self.register_ovn_agent()
|
||||
self.update_neutron_sb_cfg_key()
|
||||
LOG.info('OVN Neutron Agent started')
|
||||
|
@@ -446,6 +446,22 @@ class MetadataAgent:
|
||||
'Chassis_Private', self.chassis,
|
||||
('external_ids', external_ids)).execute(check_error=True)
|
||||
|
||||
def _cleanup_previous_tags(self):
|
||||
"""Remove any existing tag related to the OVN agent
|
||||
|
||||
The OVN Metadata agent is deprecated and marked for removal in 2026.2.
|
||||
|
||||
While both agents can provide the same functionality (OVN Metadata
|
||||
agent and OVN agent with the metadata extension), it is needed to
|
||||
provide a cleanup method for any leftover tag from the other agent.
|
||||
"""
|
||||
metadata_keys = (ovn_const.OVN_AGENT_NEUTRON_SB_CFG_KEY,
|
||||
ovn_const.OVN_AGENT_NEUTRON_DESC_KEY,
|
||||
ovn_const.OVN_AGENT_NEUTRON_ID_KEY)
|
||||
self.sb_idl.db_remove(
|
||||
'Chassis_Private', self.chassis, 'external_ids',
|
||||
*metadata_keys, if_exists=True).execute(check_error=True)
|
||||
|
||||
@_sync_lock
|
||||
def resync(self):
|
||||
"""Resync the agent.
|
||||
@@ -488,6 +504,7 @@ class MetadataAgent:
|
||||
self.sync(provision=False)
|
||||
|
||||
# Register the agent with its corresponding Chassis
|
||||
self._cleanup_previous_tags()
|
||||
self.register_metadata_agent()
|
||||
self._update_chassis_private_config()
|
||||
self._update_metadata_sb_cfg_key()
|
||||
|
@@ -150,3 +150,26 @@ class TestOVNNeutronAgentMetadataExtension(TestOVNNeutronAgentBase):
|
||||
# Check Unix proxy is running.
|
||||
metadata_extension = self.ovn_agent[METADATA_EXTENSION]
|
||||
self.assertIsNotNone(metadata_extension._proxy._server)
|
||||
|
||||
def test__cleanup_previous_tags(self):
|
||||
external_ids = {
|
||||
ovn_const.OVN_AGENT_METADATA_SB_CFG_KEY: '1',
|
||||
ovn_const.OVN_AGENT_METADATA_DESC_KEY: 'description',
|
||||
ovn_const.OVN_AGENT_METADATA_ID_KEY: uuidutils.generate_uuid()}
|
||||
self.ovn_agent.sb_idl.db_set(
|
||||
'Chassis_Private', self.ovn_agent.chassis,
|
||||
('external_ids', external_ids)).execute(check_error=True)
|
||||
|
||||
self.ovn_agent._cleanup_previous_tags()
|
||||
external_ids = self.ovn_agent.sb_idl.db_get(
|
||||
'Chassis_Private', self.ovn_agent.chassis,
|
||||
'external_ids').execute(check_error=True)
|
||||
for _key in (ovn_const.OVN_AGENT_METADATA_SB_CFG_KEY,
|
||||
ovn_const.OVN_AGENT_METADATA_DESC_KEY,
|
||||
ovn_const.OVN_AGENT_METADATA_ID_KEY):
|
||||
self.assertNotIn(_key, external_ids)
|
||||
|
||||
# Just in case, check that we are NOT deleting the needed tags.
|
||||
# NOTE(ralonsoh): OVN_AGENT_METADATA_ID_KEY is missing here, there is
|
||||
# a bug to add it (LP#2118876)
|
||||
self.assertIn(ovn_const.OVN_AGENT_NEUTRON_SB_CFG_KEY, external_ids)
|
||||
|
@@ -689,3 +689,26 @@ class TestMetadataAgent(base.TestOVNFunctionalBase):
|
||||
timeout=1,
|
||||
exception=NoDatapathProvision(
|
||||
"Provisioning wasn't triggered"))
|
||||
|
||||
def test__cleanup_previous_tags(self):
|
||||
external_ids = {
|
||||
ovn_const.OVN_AGENT_NEUTRON_SB_CFG_KEY: '1',
|
||||
ovn_const.OVN_AGENT_NEUTRON_DESC_KEY: 'description',
|
||||
ovn_const.OVN_AGENT_NEUTRON_ID_KEY: uuidutils.generate_uuid()}
|
||||
self.sb_api.db_set(
|
||||
'Chassis_Private', self.chassis_name,
|
||||
('external_ids', external_ids)).execute(check_error=True)
|
||||
|
||||
self.agent._cleanup_previous_tags()
|
||||
external_ids = self.sb_api.db_get(
|
||||
'Chassis_Private', self.chassis_name,
|
||||
'external_ids').execute(check_error=True)
|
||||
for _key in (ovn_const.OVN_AGENT_NEUTRON_SB_CFG_KEY,
|
||||
ovn_const.OVN_AGENT_NEUTRON_DESC_KEY,
|
||||
ovn_const.OVN_AGENT_NEUTRON_ID_KEY):
|
||||
self.assertNotIn(_key, external_ids)
|
||||
|
||||
# Just in case, check that we are NOT deleting the needed tags.
|
||||
for _key in (ovn_const.OVN_AGENT_METADATA_SB_CFG_KEY,
|
||||
ovn_const.OVN_AGENT_METADATA_ID_KEY):
|
||||
self.assertIn(_key, external_ids)
|
||||
|
Reference in New Issue
Block a user