Browse Source

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)
changes/24/743724/1
Carlos Goncalves 2 months ago
parent
commit
5dc9898984
3 changed files with 7 additions and 6 deletions
  1. +3
    -2
      octavia/common/config.py
  2. +2
    -2
      octavia/common/jinja/haproxy/combined_listeners/jinja_cfg.py
  3. +2
    -2
      octavia/common/jinja/haproxy/split_listeners/jinja_cfg.py

+ 3
- 2
octavia/common/config.py View File

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


+ 2
- 2
octavia/common/jinja/haproxy/combined_listeners/jinja_cfg.py 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


+ 2
- 2
octavia/common/jinja/haproxy/split_listeners/jinja_cfg.py View File

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


Loading…
Cancel
Save