Skip to content

Commit a1732d4

Browse files
cubeekkarelyatin
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. TrivialFix Closes-bug: #2069442 Depends-On: https://review.opendev.org/c/openstack/nova/+/925000 Change-Id: I7d21e4adc27fab411346e0458c92191e69ce6b30 Signed-off-by: Jakub Libosvar <[email protected]> (cherry picked from commit 8ab385f)
1 parent 82ece4f commit a1732d4

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
@@ -786,6 +786,9 @@ def _ovn_update_port(self, plugin_context, port, original_port,
786786
port['revision_number'] = db_port['revision_number']
787787
self._ovn_update_port(plugin_context, port, original_port,
788788
retry_on_revision_mismatch=False)
789+
except ovn_revision_numbers_db.StandardAttributeIDNotFound:
790+
LOG.debug("Standard attribute was not found for port %s. It was "
791+
"possibly deleted concurrently.", port['id'])
789792

790793
def create_port_postcommit(self, context):
791794
"""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
@@ -2347,8 +2347,11 @@ def test_update_port_postcommit_live_migration_revision_mismatch_once(
23472347
'_is_port_provisioning_required', lambda *_: True)
23482348
@mock.patch.object(mech_driver.OVNMechanismDriver, '_notify_dhcp_updated')
23492349
@mock.patch.object(ovn_client.OVNClient, 'update_port')
2350-
def test_update_port_postcommit_revision_mismatch_not_after_live_migration(
2351-
self, mock_update_port, mock_notify_dhcp):
2350+
def _test_update_port_postcommit_with_exception(
2351+
self, mock_update_port, mock_notify_dhcp,
2352+
raised_exc,
2353+
resource_id_name,
2354+
**exc_extra_params):
23522355
self.plugin.update_port_status = mock.Mock()
23532356
self.plugin.get_port = mock.Mock(return_value=mock.MagicMock())
23542357

@@ -2366,10 +2369,12 @@ def test_update_port_postcommit_revision_mismatch_not_after_live_migration(
23662369

23672370
fake_ctx = mock.Mock(current=fake_port, original=original_fake_port,
23682371
plugin_context=fake_context)
2372+
2373+
exc_params = exc_extra_params.copy()
2374+
exc_params[resource_id_name] = fake_port['id']
2375+
23692376
mock_update_port.side_effect = [
2370-
ovn_exceptions.RevisionConflict(
2371-
resource_id=fake_port['id'],
2372-
resource_type=ovn_const.TYPE_PORTS),
2377+
raised_exc(**exc_params),
23732378
None]
23742379

23752380
self.mech_driver.update_port_postcommit(fake_ctx)
@@ -2379,6 +2384,20 @@ def test_update_port_postcommit_revision_mismatch_not_after_live_migration(
23792384
self.assertEqual(1, mock_update_port.call_count)
23802385
mock_notify_dhcp.assert_called_with(fake_port['id'])
23812386

2387+
def test_update_port_postcommit_revision_mismatch_not_after_live_migration(
2388+
self):
2389+
self._test_update_port_postcommit_with_exception(
2390+
raised_exc=ovn_exceptions.RevisionConflict,
2391+
resource_id_name='resource_id',
2392+
resource_type=ovn_const.TYPE_PORTS,
2393+
)
2394+
2395+
def test__ovn_update_port_missing_stdattribute(self):
2396+
"""Make sure exception is handled."""
2397+
self._test_update_port_postcommit_with_exception(
2398+
raised_exc=ovn_revision_numbers_db.StandardAttributeIDNotFound,
2399+
resource_id_name='resource_uuid')
2400+
23822401
def test_agent_alive_true(self):
23832402
chassis_private = self._add_chassis_private(5)
23842403
for agent_type in (ovn_const.OVN_CONTROLLER_AGENT,

0 commit comments

Comments
 (0)