Skip to content

Commit 79a5647

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "fix haproxy_count to display the number of running processes"
2 parents 54e1f6f + 33a3d47 commit 79a5647

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

octavia/amphorae/backends/agent/api_server/amphora_info.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def compile_amphora_info(self, extend_lvs_driver=None):
4848
return webob.Response(json=body)
4949

5050
def compile_amphora_details(self, extend_lvs_driver=None):
51+
haproxy_loadbalancer_list = sorted(util.get_loadbalancers())
5152
haproxy_listener_list = sorted(util.get_listeners())
5253
extend_body = {}
5354
lvs_listener_list = []
@@ -73,7 +74,7 @@ def compile_amphora_details(self, extend_lvs_driver=None):
7374
'networks': self._get_networks(),
7475
'active': True,
7576
'haproxy_count':
76-
self._count_haproxy_processes(haproxy_listener_list),
77+
self._count_haproxy_processes(haproxy_loadbalancer_list),
7778
'cpu_count': os.cpu_count(),
7879
'cpu': {
7980
'total': cpu['total'],

octavia/tests/unit/amphorae/backends/agent/api_server/test_amphora_info.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class TestAmphoraInfo(base.TestCase):
3939
FAKE_LISTENER_ID_3 = uuidutils.generate_uuid()
4040
FAKE_LISTENER_ID_4 = uuidutils.generate_uuid()
4141
LB_ID_1 = uuidutils.generate_uuid()
42+
LB_ID_2 = uuidutils.generate_uuid()
4243

4344
def setUp(self):
4445
super().setUp()
@@ -113,6 +114,8 @@ def test_compile_amphora_info_for_udp(self, mock_gethostname,
113114
@mock.patch('octavia.amphorae.backends.agent.api_server.util.'
114115
'get_listeners', return_value=[FAKE_LISTENER_ID_1,
115116
FAKE_LISTENER_ID_2])
117+
@mock.patch('octavia.amphorae.backends.agent.api_server.util.'
118+
'get_loadbalancers', return_value=[LB_ID_1, LB_ID_2])
116119
@mock.patch('octavia.amphorae.backends.agent.api_server.'
117120
'amphora_info.AmphoraInfo._get_meminfo')
118121
@mock.patch('octavia.amphorae.backends.agent.api_server.'
@@ -129,7 +132,8 @@ def test_compile_amphora_info_for_udp(self, mock_gethostname,
129132
@mock.patch('socket.gethostname', return_value='FAKE_HOST')
130133
def test_compile_amphora_details(self, mhostname, m_count, m_pkg_version,
131134
m_load, m_get_nets, m_os, m_cpu,
132-
mget_mem, mget_listener):
135+
mget_mem, mget_loadbalancers,
136+
mget_listeners):
133137
mget_mem.return_value = {'SwapCached': 0, 'Buffers': 344792,
134138
'MemTotal': 21692784, 'Cached': 4271856,
135139
'Slab': 534384, 'MemFree': 12685624,
@@ -183,6 +187,7 @@ def test_compile_amphora_details(self, mhostname, m_count, m_pkg_version,
183187
u'topology_status': u'OK'}
184188
actual = self.amp_info.compile_amphora_details()
185189
self.assertEqual(expected_dict, actual.json)
190+
m_count.assert_called_once_with(sorted(mget_loadbalancers()))
186191
api_server.VERSION = original_version
187192

188193
@mock.patch('octavia.amphorae.backends.agent.api_server.util.'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
Fix amphora haproxy_count to return the number of
5+
haproxy processes that are running.

0 commit comments

Comments
 (0)