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 a0c53e13739..19ec2d8076a 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py @@ -794,6 +794,9 @@ class OVNMechanismDriver(api.MechanismDriver): port['revision_number'] = db_port['revision_number'] self._ovn_update_port(plugin_context, port, original_port, retry_on_revision_mismatch=False) + except ovn_revision_numbers_db.StandardAttributeIDNotFound: + LOG.debug("Standard attribute was not found for port %s. It was " + "possibly deleted concurrently.", port['id']) def create_port_postcommit(self, context): """Create a port. 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 3ff895e5f31..41e4b002bc5 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 @@ -2454,8 +2454,11 @@ class TestOVNMechanismDriver(TestOVNMechanismDriverBase): '_is_port_provisioning_required', lambda *_: True) @mock.patch.object(mech_driver.OVNMechanismDriver, '_notify_dhcp_updated') @mock.patch.object(ovn_client.OVNClient, 'update_port') - def test_update_port_postcommit_revision_mismatch_not_after_live_migration( - self, mock_update_port, mock_notify_dhcp): + def _test_update_port_postcommit_with_exception( + self, mock_update_port, mock_notify_dhcp, + raised_exc, + resource_id_name, + **exc_extra_params): self.plugin.update_port_status = mock.Mock() self.plugin.get_port = mock.Mock(return_value=mock.MagicMock()) @@ -2473,10 +2476,12 @@ class TestOVNMechanismDriver(TestOVNMechanismDriverBase): fake_ctx = mock.Mock(current=fake_port, original=original_fake_port, plugin_context=fake_context) + + exc_params = exc_extra_params.copy() + exc_params[resource_id_name] = fake_port['id'] + mock_update_port.side_effect = [ - ovn_exceptions.RevisionConflict( - resource_id=fake_port['id'], - resource_type=ovn_const.TYPE_PORTS), + raised_exc(**exc_params), None] self.mech_driver.update_port_postcommit(fake_ctx) @@ -2486,6 +2491,20 @@ class TestOVNMechanismDriver(TestOVNMechanismDriverBase): self.assertEqual(1, mock_update_port.call_count) mock_notify_dhcp.assert_called_with(fake_port['id']) + def test_update_port_postcommit_revision_mismatch_not_after_live_migration( + self): + self._test_update_port_postcommit_with_exception( + raised_exc=ovn_exceptions.RevisionConflict, + resource_id_name='resource_id', + resource_type=ovn_const.TYPE_PORTS, + ) + + def test__ovn_update_port_missing_stdattribute(self): + """Make sure exception is handled.""" + self._test_update_port_postcommit_with_exception( + raised_exc=ovn_revision_numbers_db.StandardAttributeIDNotFound, + resource_id_name='resource_uuid') + def test_agent_alive_true(self): chassis_private = self._add_chassis_private(5) for agent_type in (ovn_const.OVN_CONTROLLER_AGENT,