Skip to content

Commit 42cc387

Browse files
cubeekbrianphaley
authored andcommitted
Don't print traceback if standard attr is missing on update
If northd is very busy, it may happen port is deleted when handling an LSP down event causing standard attribute being gone when bumping ovn revision number. This is because the port is set down in SB DB first and then northd propagates that to NB DB, and then the event is emited. This patch just makes sure the traceback is not printed in case this happens. Conflicts: neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py TrivialFix Closes-bug: #2069442 Change-Id: I7d21e4adc27fab411346e0458c92191e69ce6b30 Signed-off-by: Jakub Libosvar <[email protected]> (cherry picked from commit 8ab385f)
1 parent 6b1208f commit 42cc387

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,9 @@ def _ovn_update_port(self, plugin_context, port, original_port,
776776
port['revision_number'] = db_port['revision_number']
777777
self._ovn_update_port(plugin_context, port, original_port,
778778
retry_on_revision_mismatch=False)
779+
except ovn_revision_numbers_db.StandardAttributeIDNotFound:
780+
LOG.debug("Standard attribute was not found for port %s. It was "
781+
"possibly deleted concurrently.", port['id'])
779782

780783
def create_port_postcommit(self, context):
781784
"""Create a port.

neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,8 +2269,11 @@ def test_update_port_postcommit_live_migration_revision_mismatch_once(
22692269
'_is_port_provisioning_required', lambda *_: True)
22702270
@mock.patch.object(mech_driver.OVNMechanismDriver, '_notify_dhcp_updated')
22712271
@mock.patch.object(ovn_client.OVNClient, 'update_port')
2272-
def test_update_port_postcommit_revision_mismatch_not_after_live_migration(
2273-
self, mock_update_port, mock_notify_dhcp):
2272+
def _test_update_port_postcommit_with_exception(
2273+
self, mock_update_port, mock_notify_dhcp,
2274+
raised_exc,
2275+
resource_id_name,
2276+
**exc_extra_params):
22742277
self.plugin.update_port_status = mock.Mock()
22752278
self.plugin.get_port = mock.Mock(return_value=mock.MagicMock())
22762279

@@ -2288,10 +2291,12 @@ def test_update_port_postcommit_revision_mismatch_not_after_live_migration(
22882291

22892292
fake_ctx = mock.Mock(current=fake_port, original=original_fake_port,
22902293
_plugin_context=fake_context)
2294+
2295+
exc_params = exc_extra_params.copy()
2296+
exc_params[resource_id_name] = fake_port['id']
2297+
22912298
mock_update_port.side_effect = [
2292-
ovn_exceptions.RevisionConflict(
2293-
resource_id=fake_port['id'],
2294-
resource_type=ovn_const.TYPE_PORTS),
2299+
raised_exc(**exc_params),
22952300
None]
22962301

22972302
self.mech_driver.update_port_postcommit(fake_ctx)
@@ -2301,6 +2306,20 @@ def test_update_port_postcommit_revision_mismatch_not_after_live_migration(
23012306
self.assertEqual(1, mock_update_port.call_count)
23022307
mock_notify_dhcp.assert_called_with(fake_port['id'])
23032308

2309+
def test_update_port_postcommit_revision_mismatch_not_after_live_migration(
2310+
self):
2311+
self._test_update_port_postcommit_with_exception(
2312+
raised_exc=ovn_exceptions.RevisionConflict,
2313+
resource_id_name='resource_id',
2314+
resource_type=ovn_const.TYPE_PORTS,
2315+
)
2316+
2317+
def test__ovn_update_port_missing_stdattribute(self):
2318+
"""Make sure exception is handled."""
2319+
self._test_update_port_postcommit_with_exception(
2320+
raised_exc=ovn_revision_numbers_db.StandardAttributeIDNotFound,
2321+
resource_id_name='resource_uuid')
2322+
23042323
def test_agent_alive_true(self):
23052324
chassis_private = self._add_chassis(5)
23062325
for agent_type in (ovn_const.OVN_CONTROLLER_AGENT,

0 commit comments

Comments
 (0)