From 5dc98989846405605b465fe13205692e6247676a Mon Sep 17 00:00:00 2001 From: Carlos Goncalves Date: Sun, 26 Jul 2020 16:40:28 +0200 Subject: [PATCH] Fix haproxy user flow log format substitution The user log format string has two special parameters: {{ project_id }} and {{ lb_id }}. These parameters are documented as being wrapped around double curly brackets and a whitespace, and are being used as so by operators/installers. However, the actual substitution is single curly bracket with no whitespace, i.e. {project_id} and {lb_id}. Fix this issue by aligning the code with the documentation. Task: 40444 Story: 2007958 Change-Id: Ifdc24033db288ec615391e576c1c77e6b35aba1f (cherry picked from commit f9f002770431ea89bc0edb38ecef18d285bef846) (cherry picked from commit c3f61aecf11354e26edaebf5bdfeef9466830401) --- octavia/common/config.py | 5 +++-- octavia/common/jinja/haproxy/combined_listeners/jinja_cfg.py | 4 ++-- octavia/common/jinja/haproxy/split_listeners/jinja_cfg.py | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/octavia/common/config.py b/octavia/common/config.py index dd40b70047..409f1e39b0 100644 --- a/octavia/common/config.py +++ b/octavia/common/config.py @@ -332,8 +332,9 @@ haproxy_amphora_opts = [ help=_('Size of the HAProxy stick table. Accepts k, m, g ' 'suffixes. Example: 10k')), cfg.StrOpt('user_log_format', - default='{project_id} {lb_id} %f %ci %cp %t %{+Q}r %ST %B %U ' - '%[ssl_c_verify] %{+Q}[ssl_c_s_dn] %b %s %Tt %tsc', + default='{{ project_id }} {{ lb_id }} %f %ci %cp %t %{+Q}r %ST ' + '%B %U %[ssl_c_verify] %{+Q}[ssl_c_s_dn] %b %s %Tt ' + '%tsc', help=_('Log format string for user flow logging.')), # REST server diff --git a/octavia/common/jinja/haproxy/combined_listeners/jinja_cfg.py b/octavia/common/jinja/haproxy/combined_listeners/jinja_cfg.py index 4a8a1f9787..b48347fd4e 100644 --- a/octavia/common/jinja/haproxy/combined_listeners/jinja_cfg.py +++ b/octavia/common/jinja/haproxy/combined_listeners/jinja_cfg.py @@ -121,8 +121,8 @@ class JinjaTemplater(object): def _format_log_string(self, load_balancer, protocol): log_format = CONF.haproxy_amphora.user_log_format.replace( - '{project_id}', load_balancer.project_id) - log_format = log_format.replace('{lb_id}', load_balancer.id) + '{{ project_id }}', load_balancer.project_id) + log_format = log_format.replace('{{ lb_id }}', load_balancer.id) # Order of these filters matter. # TODO(johnsom) Remove when HAProxy handles the format string diff --git a/octavia/common/jinja/haproxy/split_listeners/jinja_cfg.py b/octavia/common/jinja/haproxy/split_listeners/jinja_cfg.py index c0cfb966d9..29effdd027 100644 --- a/octavia/common/jinja/haproxy/split_listeners/jinja_cfg.py +++ b/octavia/common/jinja/haproxy/split_listeners/jinja_cfg.py @@ -123,8 +123,8 @@ class JinjaTemplater(object): def _format_log_string(self, load_balancer, protocol): log_format = CONF.haproxy_amphora.user_log_format.replace( - '{project_id}', load_balancer.project_id) - log_format = log_format.replace('{lb_id}', load_balancer.id) + '{{ project_id }}', load_balancer.project_id) + log_format = log_format.replace('{{ lb_id }}', load_balancer.id) # Order of these filters matter. # TODO(johnsom) Remove when HAProxy handles the format string