From 155ed969ae0b034820bf766ac2e3b7d97bbf8d4a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Serhat=20R=C4=B1fat=20Demircan?= <demircan.serhat@gmail.com>
Date: Thu, 22 Sep 2022 15:36:58 +0300
Subject: [PATCH] set haproxy balance algorithm to roundrobin for horizon

Currently kolla-ansible sets haproxy balance algorithm to source for
horizon. We can set it to round-robin if the cache backend is memcached
or using the database as the session storage backend. So we can
distribute http requests evenly to all available horizon instances.

Closes-Bug: #1990523
Change-Id: I0721cadcf53d59947bc0db6a193bfafe49c41ad3
---
 ansible/roles/horizon/defaults/main.yml              | 4 ++--
 releasenotes/notes/bug-1990523-d29021229e3102f2.yaml | 6 ++++++
 2 files changed, 8 insertions(+), 2 deletions(-)
 create mode 100644 releasenotes/notes/bug-1990523-d29021229e3102f2.yaml

diff --git a/ansible/roles/horizon/defaults/main.yml b/ansible/roles/horizon/defaults/main.yml
index 77f76ecd1a..8ee5f1fac3 100644
--- a/ansible/roles/horizon/defaults/main.yml
+++ b/ansible/roles/horizon/defaults/main.yml
@@ -42,7 +42,7 @@ horizon_services:
         frontend_http_extra:
           - "use_backend acme_client_back if { path_reg ^/.well-known/acme-challenge/.+ }"
         backend_http_extra:
-          - "balance source"
+          - "balance {{ 'roundrobin' if enable_memcached | bool or horizon_backend_database | bool else 'source' }}"
         tls_backend: "{{ horizon_enable_tls_backend }}"
       horizon_redirect:
         enabled: "{{ enable_horizon | bool and kolla_enable_tls_internal | bool }}"
@@ -59,7 +59,7 @@ horizon_services:
         frontend_http_extra:
           - "use_backend acme_client_back if { path_reg ^/.well-known/acme-challenge/.+ }"
         backend_http_extra:
-          - "balance source"
+          - "balance {{ 'roundrobin' if enable_memcached | bool or horizon_backend_database | bool else 'source' }}"
         tls_backend: "{{ horizon_enable_tls_backend }}"
       horizon_external_redirect:
         enabled: "{{ enable_horizon | bool and kolla_enable_tls_external | bool }}"
diff --git a/releasenotes/notes/bug-1990523-d29021229e3102f2.yaml b/releasenotes/notes/bug-1990523-d29021229e3102f2.yaml
new file mode 100644
index 0000000000..efe6badb61
--- /dev/null
+++ b/releasenotes/notes/bug-1990523-d29021229e3102f2.yaml
@@ -0,0 +1,6 @@
+---
+other:
+  - |
+    sets balancing algorithm to round-robin for horizon
+    if memcached is enabled
+    `LP#1990523 <https://launchpad.net/bugs/1990523>`__
-- 
GitLab