]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix re-creation of the pool directory
authorVishal Agarwal <vishala@hp.com>
Wed, 25 Jun 2014 16:00:39 +0000 (21:30 +0530)
committerVishal Agarwal <vishala@hp.com>
Thu, 26 Jun 2014 14:42:42 +0000 (20:12 +0530)
Whenever vip is deleted the complete pool directory
is deleted, but since pool is still alive the get_stats
function recreates the directory. The fix prevents the
re-creation of the directory. Respective unit test case
is also modified

Change-Id: I577e8e3a51db361210aa83a6c7f9b4f61210e924
Closes-Bug: #1317871

neutron/services/loadbalancer/drivers/haproxy/namespace_driver.py
neutron/tests/unit/services/loadbalancer/drivers/haproxy/test_namespace_driver.py

index 5cece4c3a1ee8c3a3d4ea2ec9cf9172953d74deb..967c65e7fbb41913e0ae5a3dea1580cff63da8df 100644 (file)
@@ -146,7 +146,7 @@ class HaproxyNSDriver(agent_device_driver.AgentDeviceDriver):
         namespace = get_ns_name(pool_id)
         root_ns = ip_lib.IPWrapper(self.root_helper)
 
-        socket_path = self._get_state_file_path(pool_id, 'sock')
+        socket_path = self._get_state_file_path(pool_id, 'sock', False)
         if root_ns.netns.exists(namespace) and os.path.exists(socket_path):
             try:
                 s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
@@ -157,7 +157,7 @@ class HaproxyNSDriver(agent_device_driver.AgentDeviceDriver):
         return False
 
     def get_stats(self, pool_id):
-        socket_path = self._get_state_file_path(pool_id, 'sock')
+        socket_path = self._get_state_file_path(pool_id, 'sock', False)
         TYPE_BACKEND_REQUEST = 2
         TYPE_SERVER_REQUEST = 4
         if os.path.exists(socket_path):
index c8079679651f6064100f047709f228f8f74c2521..8649e03b6d6e58c4138ef7e759f8a233bdf6c472 100644 (file)
@@ -163,7 +163,7 @@ class TestHaproxyNSDriver(base.BaseTestCase):
             mock.patch('socket.socket'),
             mock.patch('os.path.exists'),
         ) as (gsp, ip_wrap, socket, path_exists):
-            gsp.side_effect = lambda x, y: '/pool/' + y
+            gsp.side_effect = lambda x, y, z: '/pool/' + y
 
             ip_wrap.return_value.netns.exists.return_value = True
             path_exists.return_value = True
@@ -210,7 +210,7 @@ class TestHaproxyNSDriver(base.BaseTestCase):
                 mock.patch('socket.socket'),
                 mock.patch('os.path.exists'),
         ) as (gsp, socket, path_exists):
-            gsp.side_effect = lambda x, y: '/pool/' + y
+            gsp.side_effect = lambda x, y, z: '/pool/' + y
             path_exists.return_value = True
             socket.return_value = socket
             socket.recv.return_value = raw_stats