Fix haproxy global maxconn with disabled listeners

global maxconn value is based on the connection-limit of the listeners
of a LB, but it includes the connection-limit of disabled listeners.
Disabled listeners are now skipped.

Closes-Bug: #2024371

Change-Id: I45500d618b307f740b8e692c49f5efdd27dc10a0
(cherry picked from commit 21682f7056)
This commit is contained in:
Gregory Thiemonge 2023-06-19 16:53:54 -04:00
parent 41e7707645
commit bd9d474b12
3 changed files with 30 additions and 0 deletions

View File

@ -265,6 +265,8 @@ class JinjaTemplater(object):
# listeners' connection limits.
connection_limit_sum = 0
for listener in listeners:
if not listener.enabled:
continue
if listener.protocol in constants.LVS_PROTOCOLS:
continue
if listener.connection_limit and listener.connection_limit > -1:

View File

@ -1559,6 +1559,28 @@ class TestHaproxyCfg(base.TestCase):
self.assertLess(ret['global_connection_limit'],
connection_limit_sum)
def test_transform_with_disabled_listeners(self):
in_amphora = sample_configs_combined.sample_amphora_tuple()
in_listeners = []
connection_limit_sum = 0
in_listener = (
sample_configs_combined.sample_listener_tuple())
connection_limit_sum += constants.HAPROXY_DEFAULT_MAXCONN
in_listeners.append(in_listener)
disabled_listener = (
sample_configs_combined.sample_listener_tuple(enabled=False))
in_listeners.append(disabled_listener)
ret = self.jinja_cfg._transform_loadbalancer(
in_amphora, in_listeners[0].load_balancer,
in_listeners, None, {})
self.assertEqual(ret['global_connection_limit'],
connection_limit_sum)
def test_transform_amphora(self):
in_amphora = sample_configs_combined.sample_amphora_tuple()
ret = self.jinja_cfg._transform_amphora(in_amphora, {})

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixed the global number of concurrent connections in haproxy when disabling
listeners. The connection-limit of disabled listeners was used to compute
this value, disabled listeners are now skipped.