]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Use an independent iptables lock per namespace
authorCarl Baldwin <carl.baldwin@hp.com>
Fri, 17 Jan 2014 19:28:10 +0000 (19:28 +0000)
committerThomas Goirand <thomas@goirand.fr>
Thu, 13 Mar 2014 07:20:12 +0000 (15:20 +0800)
Since iptables is independent from namespace to namespace, it makes
sense to use an independent lock per namespace.  This improvement is
aimed at improving the parallel performance in the L3 agent.

Partially implements blueprint: neutron-tempest-parallel

Change-Id: I15e9c9da9a7c15981757a09bc744501722d62db2

neutron/agent/linux/iptables_manager.py
neutron/common/utils.py

index f33478af68da99c802f6317f3304bd690c5feeb6..87372f03b6e247997f888f849831cf4032680045 100644 (file)
@@ -26,6 +26,7 @@ import os
 
 from neutron.agent.linux import utils as linux_utils
 from neutron.common import utils
+from neutron.openstack.common import lockutils
 from neutron.openstack.common import log as logging
 
 LOG = logging.getLogger(__name__)
@@ -351,8 +352,19 @@ class IptablesManager(object):
 
         self._apply()
 
-    @utils.synchronized('iptables', external=True)
     def _apply(self):
+        lock_name = 'iptables'
+        if self.namespace:
+            lock_name += '-' + self.namespace
+
+        try:
+            with lockutils.lock(lock_name, utils.SYNCHRONIZED_PREFIX, True):
+                LOG.debug(_('Got semaphore / lock "%s"'), lock_name)
+                return self._apply_synchronized()
+        finally:
+            LOG.debug(_('Semaphore / lock released "%s"'), lock_name)
+
+    def _apply_synchronized(self):
         """Apply the current in-memory set of iptables rules.
 
         This will blow away any rules left over from previous runs of the
index 5e8cab756f265146cba74c6e9b759c740cd398ab..1a806ab4953879c10feb9bdc0c16b77d18c350a9 100644 (file)
@@ -36,8 +36,9 @@ from neutron.openstack.common import log as logging
 
 TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
 LOG = logging.getLogger(__name__)
+SYNCHRONIZED_PREFIX = 'neutron-'
 
-synchronized = lockutils.synchronized_with_prefix('neutron-')
+synchronized = lockutils.synchronized_with_prefix(SYNCHRONIZED_PREFIX)
 
 
 def read_cached_file(filename, cache_info, reload_func=None):