Browse Source

Fix memory leak in the haproxy provider driver

The haproxy provider driver uses a dict for caching load balancer
resources (including children resources). That alone already increases
memory consumption. A neutron-server restart solves this.

But the real issue is that the driver leaves some data behind when a LB
is deleted without freeing it up (unless neutron-server is restart)
hence the memory leak.

Story: 2003802
Task: 26534

Change-Id: I7c79271998d839c6afbeb6d92f888f6acd67704e
Carlos Goncalves 7 months ago
parent
commit
111d0b2852

+ 3
- 0
neutron_lbaas/drivers/haproxy/namespace_driver.py View File

@@ -178,6 +178,9 @@ class HaproxyNSDriver(agent_device_driver.AgentDeviceDriver):
178 178
             ns = ip_lib.IPWrapper(namespace=namespace)
179 179
             ns.garbage_collect_namespace()
180 180
 
181
+        if loadbalancer_id in self.deployed_loadbalancers:
182
+            del self.deployed_loadbalancers[loadbalancer_id]
183
+
181 184
     def remove_orphans(self, known_loadbalancer_ids):
182 185
         if not os.path.exists(self.state_path):
183 186
             return

+ 1
- 0
neutron_lbaas/tests/unit/drivers/haproxy/test_namespace_driver.py View File

@@ -108,6 +108,7 @@ class TestHaproxyNSDriver(base.BaseTestCase):
108 108
                                                        namespace=ns)
109 109
         mock_shutil.assert_called_once_with('/path/' + self.lb.id)
110 110
         mock_ns.garbage_collect_namespace.assert_called_once_with()
111
+        self.assertDictEqual(self.driver.deployed_loadbalancers, {})
111 112
 
112 113
     @mock.patch('os.makedirs')
113 114
     @mock.patch('os.path.dirname')

Loading…
Cancel
Save