Fix intermittent failures in finding metada port in SB DB
The test_agent_metadata_port_ip_update_event can sometimes fail with finding the port in SB DB Port_Binding table. This is due to a race condition between when the port is commited to NB DB ,reflected in SB DB and calling lsp_bind on SB DB. This patch simply adds metadata port create event check before calling lsp_bind on the metadata port. Closes-Bug: #2012754 Change-Id: I07fa45401788da6b963830e72a7b3a3cd54662e1
This commit is contained in:
@@ -51,6 +51,18 @@ class MetadataAgentHealthEvent(event.WaitEvent):
|
|||||||
ovn_const.OVN_AGENT_METADATA_SB_CFG_KEY, 0)) >= self.sb_cfg
|
ovn_const.OVN_AGENT_METADATA_SB_CFG_KEY, 0)) >= self.sb_cfg
|
||||||
|
|
||||||
|
|
||||||
|
class MetadataPortCreateEvent(event.WaitEvent):
|
||||||
|
event_name = 'MetadataPortCreateEvent'
|
||||||
|
|
||||||
|
def __init__(self, metadata_port, timeout=5):
|
||||||
|
table = 'Port_Binding'
|
||||||
|
events = (self.ROW_CREATE,)
|
||||||
|
conditions = (('logical_port', '=', metadata_port),)
|
||||||
|
super(MetadataPortCreateEvent, self).__init__(
|
||||||
|
events, table, conditions, timeout=timeout
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestMetadataAgent(base.TestOVNFunctionalBase):
|
class TestMetadataAgent(base.TestOVNFunctionalBase):
|
||||||
OVN_BRIDGE = 'br-int'
|
OVN_BRIDGE = 'br-int'
|
||||||
FAKE_CHASSIS_HOST = 'ovn-host-fake'
|
FAKE_CHASSIS_HOST = 'ovn-host-fake'
|
||||||
@@ -132,8 +144,8 @@ class TestMetadataAgent(base.TestOVNFunctionalBase):
|
|||||||
# chassis with the nb_cfg, 1 revisions when listing the agents.
|
# chassis with the nb_cfg, 1 revisions when listing the agents.
|
||||||
self.assertTrue(row_event.wait())
|
self.assertTrue(row_event.wait())
|
||||||
|
|
||||||
def _create_metadata_port(self, txn, lswitch_name):
|
def _create_metadata_port(self, txn, lswitch_name, port_name=None):
|
||||||
mdt_port_name = 'ovn-mdt-' + uuidutils.generate_uuid()
|
mdt_port_name = port_name or 'ovn-mdt-' + uuidutils.generate_uuid()
|
||||||
txn.add(
|
txn.add(
|
||||||
self.nb_api.lsp_add(
|
self.nb_api.lsp_add(
|
||||||
lswitch_name,
|
lswitch_name,
|
||||||
@@ -144,7 +156,6 @@ class TestMetadataAgent(base.TestOVNFunctionalBase):
|
|||||||
ovn_const.OVN_CIDRS_EXT_ID_KEY: '192.168.122.123/24',
|
ovn_const.OVN_CIDRS_EXT_ID_KEY: '192.168.122.123/24',
|
||||||
ovn_const.OVN_DEVID_EXT_ID_KEY: 'ovnmeta-' + lswitch_name
|
ovn_const.OVN_DEVID_EXT_ID_KEY: 'ovnmeta-' + lswitch_name
|
||||||
}))
|
}))
|
||||||
return mdt_port_name
|
|
||||||
|
|
||||||
def _update_metadata_port_ip(self, metadata_port_name):
|
def _update_metadata_port_ip(self, metadata_port_name):
|
||||||
external_ids = {
|
external_ids = {
|
||||||
@@ -224,7 +235,14 @@ class TestMetadataAgent(base.TestOVNFunctionalBase):
|
|||||||
if update and type_ == ovn_const.LSP_TYPE_LOCALPORT:
|
if update and type_ == ovn_const.LSP_TYPE_LOCALPORT:
|
||||||
with self.nb_api.transaction(
|
with self.nb_api.transaction(
|
||||||
check_error=True, log_errors=True) as txn:
|
check_error=True, log_errors=True) as txn:
|
||||||
mdt_port_name = self._create_metadata_port(txn, lswitch_name)
|
mdt_port_name = 'ovn-mdt-' + uuidutils.generate_uuid()
|
||||||
|
metadata_port_create_event = MetadataPortCreateEvent(
|
||||||
|
mdt_port_name)
|
||||||
|
self.agent.sb_idl.idl.notify_handler.watch_event(
|
||||||
|
metadata_port_create_event)
|
||||||
|
self._create_metadata_port(txn, lswitch_name, mdt_port_name)
|
||||||
|
self.assertTrue(metadata_port_create_event.wait())
|
||||||
|
|
||||||
self.sb_api.lsp_bind(mdt_port_name, self.chassis_name).execute(
|
self.sb_api.lsp_bind(mdt_port_name, self.chassis_name).execute(
|
||||||
check_error=True, log_errors=True)
|
check_error=True, log_errors=True)
|
||||||
self._update_metadata_port_ip(mdt_port_name)
|
self._update_metadata_port_ip(mdt_port_name)
|
||||||
|
Reference in New Issue
Block a user