From 2aac2a8d78b9690a132530290667928b33b12d31 Mon Sep 17 00:00:00 2001 From: Chen Tianhao Date: Fri, 14 Jul 2023 17:23:24 +0800 Subject: [PATCH] Fix IPv6 session persistence failed When an IPv6 load balancer is created, and the pool is enabled with SOURCE IP session persistence, it does not work because the stick table only records IPv4 addresses. However, an IPv6 stick table can record both IPv4 and IPv6 addresses. Closes-Bug: #2027934 Change-Id: I1c51a5d6d6593108f431809868dcdb3d4142df45 --- .../jinja/haproxy/combined_listeners/templates/macros.j2 | 4 ++-- .../jinja/haproxy/combined_listeners/test_jinja_cfg.py | 2 +- ...x-ipv6-session-persistence-failure-d649656a44fc3bbb.yaml | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/fix-ipv6-session-persistence-failure-d649656a44fc3bbb.yaml diff --git a/octavia/common/jinja/haproxy/combined_listeners/templates/macros.j2 b/octavia/common/jinja/haproxy/combined_listeners/templates/macros.j2 index a7a6214d42..3c30a5b210 100644 --- a/octavia/common/jinja/haproxy/combined_listeners/templates/macros.j2 +++ b/octavia/common/jinja/haproxy/combined_listeners/templates/macros.j2 @@ -324,10 +324,10 @@ backend {{ pool.id }}:{{ listener.id }} {% if (pool.session_persistence.type == constants.SESSION_PERSISTENCE_SOURCE_IP) %} {% if loadbalancer.topology == constants.TOPOLOGY_ACTIVE_STANDBY %} - stick-table type ip size {{ pool.stick_size }} peers {{ + stick-table type ipv6 size {{ pool.stick_size }} peers {{ "%s_peers"|format(loadbalancer.id.replace("-", ""))|trim() }} {% else %} - stick-table type ip size {{ pool.stick_size }} + stick-table type ipv6 size {{ pool.stick_size }} {% endif %} stick on src {% elif (pool.session_persistence.type == 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 5ae68b2d83..48bfecdd56 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 @@ -922,7 +922,7 @@ class TestHaproxyCfg(base.TestCase): be = ("backend sample_pool_id_1:sample_listener_id_1\n" " mode http\n" " balance roundrobin\n" - " stick-table type ip size 10k\n" + " stick-table type ipv6 size 10k\n" " stick on src\n" " timeout check 31s\n" " option httpchk GET /index.html HTTP/1.0\\r\\n\n" diff --git a/releasenotes/notes/fix-ipv6-session-persistence-failure-d649656a44fc3bbb.yaml b/releasenotes/notes/fix-ipv6-session-persistence-failure-d649656a44fc3bbb.yaml new file mode 100644 index 0000000000..90fabbfc72 --- /dev/null +++ b/releasenotes/notes/fix-ipv6-session-persistence-failure-d649656a44fc3bbb.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixed the issue with session persistence based on source IP not working for + IPv6 load balancers. Session persistence now functions properly for IPv4, + IPv6 and dual-stack load balancers.