diff --git a/neutron/agent/l2/extensions/qos.py b/neutron/agent/l2/extensions/qos.py index 4bb1773b386..e509ec34745 100644 --- a/neutron/agent/l2/extensions/qos.py +++ b/neutron/agent/l2/extensions/qos.py @@ -16,7 +16,6 @@ import abc import collections -from neutron_lib import exceptions from oslo_concurrency import lockutils from oslo_log import log as logging import six @@ -168,7 +167,8 @@ class PortPolicyMap(object): if not port_dict: self._clean_policy_info(qos_policy_id) return - raise exceptions.PortNotFound(port_id=port['port_id']) + LOG.debug("QoS extension did not have information on port %s", + port_id) def _clean_policy_info(self, qos_policy_id): del self.qos_policy_ports[qos_policy_id] @@ -274,10 +274,5 @@ class QosAgentExtension(l2_agent_extension.L2AgentExtension): self.policy_map.update_policy(qos_policy) def _process_reset_port(self, port): - try: - self.policy_map.clean_by_port(port) - self.qos_driver.delete(port) - except exceptions.PortNotFound: - LOG.info(_LI("QoS extension did have no information about the " - "port %s that we were trying to reset"), - port['port_id']) + self.policy_map.clean_by_port(port) + self.qos_driver.delete(port) diff --git a/neutron/tests/unit/agent/l2/extensions/test_qos.py b/neutron/tests/unit/agent/l2/extensions/test_qos.py index 30bb643a365..2c7c2e80f02 100644 --- a/neutron/tests/unit/agent/l2/extensions/test_qos.py +++ b/neutron/tests/unit/agent/l2/extensions/test_qos.py @@ -15,7 +15,6 @@ import mock from neutron_lib import context -from neutron_lib import exceptions from oslo_utils import uuidutils from neutron.agent.l2.extensions import qos @@ -223,7 +222,7 @@ class QosExtensionRpcTestCase(QosExtensionBaseTestCase): def test_delete_unknown_port(self): port = self._create_test_port_dict() self.qos_ext.delete_port(self.context, port) - self.assertFalse(self.qos_ext.qos_driver.delete.called) + self.assertTrue(self.qos_ext.qos_driver.delete.called) self.assertIsNone(self.qos_ext.policy_map.get_port_policy(port)) def test__handle_notification_ignores_all_event_types_except_updated(self): @@ -415,9 +414,11 @@ class PortPolicyMapTestCase(base.BaseTestCase): self.assertNotIn(TEST_PORT['port_id'], self.policy_map.port_policies) self.assertIn(TEST_POLICY2.id, self.policy_map.known_policies) - def test_clean_by_port_raises_exception_for_unknown_port(self): - self.assertRaises(exceptions.PortNotFound, - self.policy_map.clean_by_port, TEST_PORT) + def test_clean_by_port_for_unknown_port(self): + self.policy_map._clean_policy_info = mock.Mock() + self.policy_map.clean_by_port(TEST_PORT) + + self.policy_map._clean_policy_info.assert_not_called() def test_has_policy_changed(self): self._set_ports()