Merge "Fix rsyslog configuration when disabling logs" into stable/train

This commit is contained in:
Zuul 2021-05-19 20:32:58 +00:00 committed by Gerrit Code Review
commit d1a3479aa5
3 changed files with 35 additions and 13 deletions

View File

@ -14,14 +14,19 @@
# under the License. # under the License.
#} #}
{#- Tenant traffic logs -#} {#- 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 %} 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 -%}
{#- Administrative logs -#} {#- Administrative logs -#}
{%- if admin_log_hosts -%}
{%- if forward_all_logs %} {%- 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 {% 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 %}
{% else %} {% 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 -%} 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 -%} {%- endif -%}
{%- endif -%}
{%- if disable_local_log_storage -%} {%- if disable_local_log_storage -%}
*.* stop *.* stop
{%- endif -%} {%- endif -%}

View File

@ -21,24 +21,21 @@ import octavia.tests.unit.base as base
class LoggingJinjaTestCase(base.TestCase): class LoggingJinjaTestCase(base.TestCase):
def setUp(self): def test_build_agent_config(self):
super(LoggingJinjaTestCase, self).setUp() conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
conf.config(debug=False)
self.conf = oslo_fixture.Config(cfg.CONF) conf.config(
self.conf.config(debug=False)
self.conf.config(
group="amphora_agent", group="amphora_agent",
admin_log_targets='192.0.2.17:10514,192.51.100.4:10514') admin_log_targets='192.0.2.17:10514,192.51.100.4:10514')
self.conf.config( conf.config(
group="amphora_agent", group="amphora_agent",
tenant_log_targets='192.0.2.7:20514,192.51.100.9:20514') tenant_log_targets='192.0.2.7:20514,192.51.100.9:20514')
self.conf.config(group="amphora_agent", conf.config(group="amphora_agent",
log_protocol=lib_consts.PROTOCOL_UDP) log_protocol=lib_consts.PROTOCOL_UDP)
self.conf.config(group="amphora_agent", log_retry_count=5) conf.config(group="amphora_agent", log_retry_count=5)
self.conf.config(group="amphora_agent", log_retry_interval=2) conf.config(group="amphora_agent", log_retry_interval=2)
self.conf.config(group="amphora_agent", log_queue_size=10000) conf.config(group="amphora_agent", log_queue_size=10000)
def test_build_agent_config(self):
lj = logging_jinja_cfg.LoggingJinjaTemplater() lj = logging_jinja_cfg.LoggingJinjaTemplater()
expected_config = ( expected_config = (
u'local0.=info action(type="omfwd" target="192.0.2.7" ' u'local0.=info action(type="omfwd" target="192.0.2.7" '
@ -59,3 +56,18 @@ class LoggingJinjaTestCase(base.TestCase):
logging_cfg = lj.build_logging_config() logging_cfg = lj.build_logging_config()
self.assertEqual(expected_config, logging_cfg) self.assertEqual(expected_config, logging_cfg)
def test_build_agent_config_disable_logs(self):
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
conf.config(debug=False)
conf.config(
group="amphora_agent",
disable_local_log_storage=True)
lj = logging_jinja_cfg.LoggingJinjaTemplater()
expected_config = (
u'*.* stop')
logging_cfg = lj.build_logging_config()
self.assertEqual(expected_config, logging_cfg)

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fix an issue with the rsyslog configuration file in the Amphora when the
log offloading feature and the local log storage feature are both disabled.