From 6d3290ab39db687d34c02caebfbb3d32c90e9cdf Mon Sep 17 00:00:00 2001 From: Oleg Bondarev Date: Fri, 13 Dec 2013 18:22:32 +0400 Subject: [PATCH] LBaaS: synchronize haproxy deploy/undeploy_instance methods 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 --- .../services/loadbalancer/drivers/haproxy/namespace_driver.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/neutron/services/loadbalancer/drivers/haproxy/namespace_driver.py b/neutron/services/loadbalancer/drivers/haproxy/namespace_driver.py index 03ff795a78..b4b56a3aed 100644 --- a/neutron/services/loadbalancer/drivers/haproxy/namespace_driver.py +++ b/neutron/services/loadbalancer/drivers/haproxy/namespace_driver.py @@ -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