From d83375960c3716241dd1d5e60fd773a647be0eda Mon Sep 17 00:00:00 2001 From: Jakub Libosvar Date: Mon, 10 Aug 2015 08:37:13 +0000 Subject: [PATCH] Add thread locks on port routines for qos ext Only one routine can be executed at one time. Handling port updates or creations is a critical section of qos agent extension. With this patch only one routine can be executed and in case of incoming update/create, execution routine must wait until second routine is done with its job. Change-Id: I28931d2be00dd87a8155a50afe008e03e9699f17 Partially-Implements: blueprint quantum-qos-api --- neutron/agent/l2/extensions/qos.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/neutron/agent/l2/extensions/qos.py b/neutron/agent/l2/extensions/qos.py index 736cc1458a7..891084bf77a 100644 --- a/neutron/agent/l2/extensions/qos.py +++ b/neutron/agent/l2/extensions/qos.py @@ -16,6 +16,7 @@ import abc import collections +from oslo_concurrency import lockutils from oslo_config import cfg import six @@ -100,6 +101,7 @@ class QosAgentExtension(agent_extension.AgentCoreResourceExtension): topic = resources_rpc.resource_type_versioned_topic(resource_type) connection.create_consumer(topic, endpoints, fanout=True) + @lockutils.synchronized('qos-port') def _handle_notification(self, qos_policy, event_type): # server does not allow to remove a policy that is attached to any # port, so we ignore DELETED events. Also, if we receive a CREATED @@ -108,6 +110,7 @@ class QosAgentExtension(agent_extension.AgentCoreResourceExtension): if event_type == events.UPDATED: self._process_update_policy(qos_policy) + @lockutils.synchronized('qos-port') def handle_port(self, context, port): """Handle agent QoS extension for port. @@ -126,7 +129,6 @@ class QosAgentExtension(agent_extension.AgentCoreResourceExtension): port_id in self.qos_policy_ports[qos_policy_id]): return - # TODO(QoS): handle race condition between push and pull APIs self.qos_policy_ports[qos_policy_id][port_id] = port self.known_ports.add(port_id) qos_policy = self.resource_rpc.pull(