Clear QoS rules from ports without a qos policy.

This patch addresses a bug where ports that had their QoS policy
removed did not have the rules deleted as the agent was restarting
and cleared the internal port info. This results in the policy still
being in effect while it has been cleared from the port qos-policy field.

Change-Id: I2e8e4aa96d2fd15b344220c4bf8a4713197fae4e
Closes-Bug: 1663908
This commit is contained in:
David Shaughnessy 2017-03-24 15:51:11 +00:00
parent 3d5d9e8957
commit 21359e29ae
2 changed files with 10 additions and 14 deletions

View File

@ -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)

View File

@ -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()