diff --git a/octavia/common/jinja/haproxy/combined_listeners/jinja_cfg.py b/octavia/common/jinja/haproxy/combined_listeners/jinja_cfg.py index 094ea900fb..60f6798864 100644 --- a/octavia/common/jinja/haproxy/combined_listeners/jinja_cfg.py +++ b/octavia/common/jinja/haproxy/combined_listeners/jinja_cfg.py @@ -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: diff --git a/octavia/tests/unit/common/jinja/haproxy/combined_listeners/test_jinja_cfg.py b/octavia/tests/unit/common/jinja/haproxy/combined_listeners/test_jinja_cfg.py index 63c11802d9..b253a96de6 100644 --- a/octavia/tests/unit/common/jinja/haproxy/combined_listeners/test_jinja_cfg.py +++ b/octavia/tests/unit/common/jinja/haproxy/combined_listeners/test_jinja_cfg.py @@ -1558,6 +1558,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, {}) diff --git a/releasenotes/notes/fix-haproxy-maxconn-with-disabled-listeners-fa89f762a94b8fe9.yaml b/releasenotes/notes/fix-haproxy-maxconn-with-disabled-listeners-fa89f762a94b8fe9.yaml new file mode 100644 index 0000000000..1642a97aa2 --- /dev/null +++ b/releasenotes/notes/fix-haproxy-maxconn-with-disabled-listeners-fa89f762a94b8fe9.yaml @@ -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.