]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
LBaaS: synchronize haproxy deploy/undeploy_instance methods
authorOleg Bondarev <obondarev@mirantis.com>
Fri, 13 Dec 2013 14:22:32 +0000 (18:22 +0400)
committerOleg Bondarev <obondarev@mirantis.com>
Fri, 13 Dec 2013 15:03:40 +0000 (19:03 +0400)
When creating/deleting lbaas objects at a high rate (like tempest api tests do)
deploy/undeploy_unstance methods of haproxy namespace driver
may be executed concurrently which leads to different conflicts with
network namespaces and interfaces created by the diver.

@synchronized decorator should be used in order to ensure that only one thread
will execute one of the methods at a time.

Closes-Bug: #1260692

Change-Id: Ibe86653c20c9a4e0b4e7b3b2cefbd445428b82da

neutron/services/loadbalancer/drivers/haproxy/namespace_driver.py

index 03ff795a78be8114a32eb45cc8d2117fb6efd18a..b4b56a3aed65f1d05b40878f3c9d45082d28614e 100644 (file)
@@ -26,6 +26,7 @@ from neutron.agent.common import config
 from neutron.agent.linux import ip_lib
 from neutron.agent.linux import utils
 from neutron.common import exceptions
+from neutron.common import utils as n_utils
 from neutron.openstack.common import importutils
 from neutron.openstack.common import log as logging
 from neutron.plugins.common import constants
@@ -116,6 +117,7 @@ class HaproxyNSDriver(agent_device_driver.AgentDeviceDriver):
         # remember the pool<>port mapping
         self.pool_to_port_id[pool_id] = logical_config['vip']['port']['id']
 
+    @n_utils.synchronized('haproxy-driver')
     def undeploy_instance(self, pool_id):
         namespace = get_ns_name(pool_id)
         ns = ip_lib.IPWrapper(self.root_helper, namespace)
@@ -266,6 +268,7 @@ class HaproxyNSDriver(agent_device_driver.AgentDeviceDriver):
         interface_name = self.vif_driver.get_device_name(Wrap(port_stub))
         self.vif_driver.unplug(interface_name, namespace=namespace)
 
+    @n_utils.synchronized('haproxy-driver')
     def deploy_instance(self, logical_config):
         # do actual deploy only if vip is configured and active
         if ('vip' not in logical_config or