]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Add thread locks on port routines for qos ext
authorJakub Libosvar <libosvar@redhat.com>
Mon, 10 Aug 2015 08:37:13 +0000 (08:37 +0000)
committerJakub Libosvar <libosvar@redhat.com>
Mon, 10 Aug 2015 08:41:23 +0000 (08:41 +0000)
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

index 736cc1458a743353bd5fc6c9051eb5a051efc5af..891084bf77aabfd0c3b5e93c3bf41007526c3576 100644 (file)
@@ -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(