From 5c760df3d5f1886290b8dd86eb515acc06e66c9a Mon Sep 17 00:00:00 2001
From: Jason Anderson <jasonanderson@uchicago.edu>
Date: Mon, 13 Apr 2020 15:06:00 -0500
Subject: [PATCH] [horizon] Move 'balance' HAProxy keyword

The "balance" keyword is not valid in a frontend section. From the
HAProxy documentation[1]:

balance <algorithm> [ <arguments> ]
balance url_param <param> [check_post [<max_wait>]]
  Define the load balancing algorithm to be used in a backend.
  May be used in sections :   defaults | frontend | listen | backend
                                 yes   |    no    |   yes  |   yes

When running HAProxy using the "split" template style, where a
frontend/backend pair are used instead of one listen section, HAProxy
will emit warnings for the Horizon config due to this.

[1]: https://www.haproxy.org/download/1.5/doc/configuration.txt

Closes-Bug: #1872540
Change-Id: I91cee275d91a51944298618493f4ea0cd80282cc
---
 ansible/roles/horizon/defaults/main.yml              | 4 ++--
 releasenotes/notes/bug-1872540-0e9bed299f657b25.yaml | 5 +++++
 2 files changed, 7 insertions(+), 2 deletions(-)
 create mode 100644 releasenotes/notes/bug-1872540-0e9bed299f657b25.yaml

diff --git a/ansible/roles/horizon/defaults/main.yml b/ansible/roles/horizon/defaults/main.yml
index b2ebf085d8..17c9d8f8a9 100644
--- a/ansible/roles/horizon/defaults/main.yml
+++ b/ansible/roles/horizon/defaults/main.yml
@@ -45,7 +45,7 @@ horizon_services:
         external: false
         port: "{% if kolla_enable_tls_internal|bool %}443{% else %}{{ horizon_port }}{% endif %}"
         listen_port: "{{ horizon_listen_port }}"
-        frontend_http_extra:
+        backend_http_extra:
           - "balance source"
       horizon_redirect:
         enabled: "{{ enable_horizon|bool and kolla_enable_tls_internal|bool }}"
@@ -59,7 +59,7 @@ horizon_services:
         external: true
         port: "{% if kolla_enable_tls_external|bool %}443{% else %}{{ horizon_port }}{% endif %}"
         listen_port: "{{ horizon_listen_port }}"
-        frontend_http_extra:
+        backend_http_extra:
           - "balance source"
       horizon_external_redirect:
         enabled: "{{ enable_horizon|bool and kolla_enable_tls_external|bool }}"
diff --git a/releasenotes/notes/bug-1872540-0e9bed299f657b25.yaml b/releasenotes/notes/bug-1872540-0e9bed299f657b25.yaml
new file mode 100644
index 0000000000..c5856d68cf
--- /dev/null
+++ b/releasenotes/notes/bug-1872540-0e9bed299f657b25.yaml
@@ -0,0 +1,5 @@
+---
+fixes:
+  - |
+    Fixes source-IP-based load balancing for Horizon when using the
+    "split" HAProxy service template.
-- 
GitLab