Merge "Fix Amphora RSyslog configuration for TCP failover" into stable/train

This commit is contained in:
Zuul 2022-03-15 17:21:49 +00:00 committed by Gerrit Code Review
commit 82e3ede958
3 changed files with 73 additions and 21 deletions

View File

@ -15,17 +15,41 @@
#}
{#- Tenant traffic logs -#}
{%- if tenant_log_hosts -%}
local{{ user_log_facility }}.=info {% for host in tenant_log_hosts %}{% if not loop.first %}&{% endif %}action(type="omfwd" target="{{ host['host'] }}" port="{{ host['port'] }}" protocol="{{ protocol }}" action.resumeRetryCount="{{ retry_count }}" action.resumeInterval="{{ retry_interval }}" queue.type="linkedList" queue.size="{{ queue_size }}" {% if not loop.first %}action.execOnlyWhenPreviousIsSuspended="on"{% endif %}){% endfor %}
{%- endif -%}
ruleset(name="tenant_forwarding" queue.type="linkedList" queue.size="{{ queue_size }}") {
{%- for host in tenant_log_hosts %}
action(type="omfwd"
target="{{ host['host'] }}"
port="{{ host['port'] }}"
protocol="{{ protocol }}"
action.resumeRetryCount="{{ retry_count }}"
action.resumeInterval="{{ retry_interval }}"
{% if not loop.first %}action.execOnlyWhenPreviousIsSuspended="on"{%- endif -%}
)
{%- endfor %}
}
local{{ user_log_facility }}.=info call tenant_forwarding
{% endif %}
{#- Administrative logs -#}
{%- if admin_log_hosts -%}
{% if admin_log_hosts %}
ruleset(name="admin_forwarding" queue.type="linkedList" queue.size="{{ queue_size }}") {
{%- for host in admin_log_hosts %}
action(type="omfwd"
target="{{ host['host'] }}"
port="{{ host['port'] }}"
protocol="{{ protocol }}"
action.resumeRetryCount="{{ retry_count }}"
action.resumeInterval="{{ retry_interval }}"
{% if not loop.first %}action.execOnlyWhenPreviousIsSuspended="on"{%- endif -%}
)
{%- endfor %}
}
{%- if forward_all_logs %}
*.*;local{{ user_log_facility }}.none {% for host in admin_log_hosts %}{% if not loop.first %}&{% endif %}action(type="omfwd" target="{{ host['host'] }}" port="{{ host['port'] }}" protocol="{{ protocol }}" action.resumeRetryCount="{{ retry_count }}" action.resumeInterval="{{ retry_interval }}" queue.type="linkedList" queue.size="{{ queue_size }}" {% if not loop.first %}action.execOnlyWhenPreviousIsSuspended="on"{% endif %}){% endfor %}
*.*;local{{ user_log_facility }}.none call admin_forwarding
{% else %}
local{{ admin_log_facility }}.* {% for host in admin_log_hosts %}{% if not loop.first %}&{% endif %}action(type="omfwd" target="{{ host['host'] }}" port="{{ host['port'] }}" protocol="{{ protocol }}" action.resumeRetryCount="{{ retry_count }}" action.resumeInterval="{{ retry_interval }}" queue.type="linkedList" queue.size="{{ queue_size }}" {% if not loop.first %}action.execOnlyWhenPreviousIsSuspended="on"{% endif %}){% endfor -%}
{%- endif -%}
local{{ admin_log_facility }}.* call admin_forwarding
{%- endif -%}
{% endif %}
{%- if disable_local_log_storage -%}
*.* stop

View File

@ -38,21 +38,44 @@ class LoggingJinjaTestCase(base.TestCase):
lj = logging_jinja_cfg.LoggingJinjaTemplater()
expected_config = (
u'local0.=info action(type="omfwd" target="192.0.2.7" '
'port="20514" protocol="UDP" action.resumeRetryCount="5" '
'action.resumeInterval="2" queue.type="linkedList" '
'queue.size="10000" )&action(type="omfwd" target="192.51.100.9" '
'port="20514" protocol="UDP" action.resumeRetryCount="5" '
'action.resumeInterval="2" queue.type="linkedList" '
'queue.size="10000" action.execOnlyWhenPreviousIsSuspended="on")\n'
'local1.* action(type="omfwd" target="192.0.2.17" port="10514" '
'protocol="UDP" action.resumeRetryCount="5" '
'action.resumeInterval="2" queue.type="linkedList" '
'queue.size="10000" )&action(type="omfwd" target="192.51.100.4" '
'port="10514" protocol="UDP" action.resumeRetryCount="5" '
'action.resumeInterval="2" queue.type="linkedList" '
'queue.size="10000" action.execOnlyWhenPreviousIsSuspended="on")')
'ruleset(name="tenant_forwarding" queue.type="linkedList" '
'queue.size="10000") {\n'
' action(type="omfwd"\n'
' target="192.0.2.7"\n'
' port="20514"\n'
' protocol="UDP"\n'
' action.resumeRetryCount="5"\n'
' action.resumeInterval="2"\n'
' )\n'
' action(type="omfwd"\n'
' target="192.51.100.9"\n'
' port="20514"\n'
' protocol="UDP"\n'
' action.resumeRetryCount="5"\n'
' action.resumeInterval="2"\n'
' action.execOnlyWhenPreviousIsSuspended="on")\n'
'}\n'
'local0.=info call tenant_forwarding\n'
'\n'
'ruleset(name="admin_forwarding" queue.type="linkedList" '
'queue.size="10000") {\n'
' action(type="omfwd"\n'
' target="192.0.2.17"\n'
' port="10514"\n'
' protocol="UDP"\n'
' action.resumeRetryCount="5"\n'
' action.resumeInterval="2"\n'
' )\n'
' action(type="omfwd"\n'
' target="192.51.100.4"\n'
' port="10514"\n'
' protocol="UDP"\n'
' action.resumeRetryCount="5"\n'
' action.resumeInterval="2"\n'
' action.execOnlyWhenPreviousIsSuspended="on")\n'
'}\n'
'local1.* call admin_forwarding'
)
logging_cfg = lj.build_logging_config()
self.assertEqual(expected_config, logging_cfg)

View File

@ -0,0 +1,5 @@
---
fixes:
- |
The generated RSyslog configuration on the amphora supports now
RSyslog failover with TCP if multiple RSyslog servers were specified.