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
This commit is contained in:
Carlos Goncalves 2020-07-26 16:40:28 +02:00
parent ae6f344359
commit f9f0027704
3 changed files with 7 additions and 6 deletions

View File

@ -357,8 +357,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

View File

@ -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

View File

@ -122,8 +122,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