From ae5a3a99fb50f938478e008b5fbb53753fa83e1c Mon Sep 17 00:00:00 2001 From: Stephen Balukoff Date: Fri, 14 Oct 2016 00:19:03 -0700 Subject: [PATCH] Update haproxy logging configuration Use httplog for appropriate listeners in default amphora image, instead of tcplog for everything. Change-Id: I162862dace86556262d25cbe8ab10433139ffc89 --- devstack/etc/octavia/haproxy.cfg | 4 ++-- octavia/common/jinja/haproxy/templates/macros.j2 | 7 +++++++ octavia/tests/unit/common/jinja/haproxy/test_jinja_cfg.py | 6 +++--- octavia/tests/unit/common/sample_configs/sample_configs.py | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/devstack/etc/octavia/haproxy.cfg b/devstack/etc/octavia/haproxy.cfg index 0e2b174e36..ddef1ed0e9 100644 --- a/devstack/etc/octavia/haproxy.cfg +++ b/devstack/etc/octavia/haproxy.cfg @@ -14,7 +14,7 @@ defaults frontend octavia-frontend-api - option tcplog + option httplog bind 0.0.0.0:OCTAVIA_PORT mode http default_backend octavia-backend-api @@ -26,4 +26,4 @@ backend octavia-backend-api # the devstack plugin will add entries here looking like: # server octavia-main : weight 1 # server octavia-second : weight 1 -# \ No newline at end of file +# diff --git a/octavia/common/jinja/haproxy/templates/macros.j2 b/octavia/common/jinja/haproxy/templates/macros.j2 index 2cc7abc7b6..41450aad59 100644 --- a/octavia/common/jinja/haproxy/templates/macros.j2 +++ b/octavia/common/jinja/haproxy/templates/macros.j2 @@ -112,7 +112,14 @@ bind {{ lb_vip_address }}:{{ listener.protocol_port }} {{ {% macro frontend_macro(constants, listener, lb_vip_address) %} frontend {{ listener.id }} + {% if (listener.protocol.lower() == + constants.PROTOCOL_TERMINATED_HTTPS.lower() or + listener.protocol.lower() == + constants.PROTOCOL_HTTP.lower()) %} + option httplog + {% else %} option tcplog + {% endif %} {% if listener.connection_limit is defined %} maxconn {{ listener.connection_limit }} {% endif %} diff --git a/octavia/tests/unit/common/jinja/haproxy/test_jinja_cfg.py b/octavia/tests/unit/common/jinja/haproxy/test_jinja_cfg.py index 5dd3b9f1dc..df34abf594 100644 --- a/octavia/tests/unit/common/jinja/haproxy/test_jinja_cfg.py +++ b/octavia/tests/unit/common/jinja/haproxy/test_jinja_cfg.py @@ -31,7 +31,7 @@ class TestHaproxyCfg(base.TestCase): def test_render_template_tls(self): fe = ("frontend sample_listener_id_1\n" - " option tcplog\n" + " option httplog\n" " maxconn 98\n" " redirect scheme https if !{ ssl_fc }\n" " bind 10.0.0.2:443 " @@ -69,7 +69,7 @@ class TestHaproxyCfg(base.TestCase): def test_render_template_tls_no_sni(self): fe = ("frontend sample_listener_id_1\n" - " option tcplog\n" + " option httplog\n" " maxconn 98\n" " redirect scheme https if !{ ssl_fc }\n" " bind 10.0.0.2:443 " @@ -274,7 +274,7 @@ class TestHaproxyCfg(base.TestCase): def test_render_template_l7policies(self): fe = ("frontend sample_listener_id_1\n" - " option tcplog\n" + " option httplog\n" " maxconn 98\n" " bind 10.0.0.2:80\n" " mode http\n" diff --git a/octavia/tests/unit/common/sample_configs/sample_configs.py b/octavia/tests/unit/common/sample_configs/sample_configs.py index a7fa443612..7b83d29c84 100644 --- a/octavia/tests/unit/common/sample_configs/sample_configs.py +++ b/octavia/tests/unit/common/sample_configs/sample_configs.py @@ -635,7 +635,7 @@ def sample_l7rule_tuple(id, def sample_base_expected_config(frontend=None, backend=None, peers=None): if frontend is None: frontend = ("frontend sample_listener_id_1\n" - " option tcplog\n" + " option httplog\n" " maxconn 98\n" " bind 10.0.0.2:80\n" " mode http\n"