From eea54717b80f21fb790f9a7f2b4e37a49e59c72f Mon Sep 17 00:00:00 2001 From: Chun'ang Li <39114813+lerry-lee@users.noreply.github.com> Date: Mon, 6 Feb 2023 22:38:04 +0800 Subject: [PATCH] Fix rsyslogd start failed cause by rsyslog.conf is emtpy. (#13669) - Why I did it In to-sonic and multi-asic KVM-test, pretest sometimes failed. Reason is rsyslogd process can not start in teamd container. Because rsyslog.conf is empty caused by sonic-cfggen execute failed - How I did it If sonic-cfggen -d execute failed, execute without -d because the template file has the default value. - How to verify it Build image and test it over 40 times, all passed pretest. Signed-off-by: Chun'ang Li --- files/build_templates/docker_image_ctl.j2 | 4 ++++ files/image_config/rsyslog/rsyslog-container.conf.j2 | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index 2c7d8a7d6d..ec94fd4203 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -48,6 +48,10 @@ function updateSyslogConf() python -c "import jinja2, os; paths=['/usr/share/sonic/templates']; loader = jinja2.FileSystemLoader(paths); env = jinja2.Environment(loader=loader, trim_blocks=True); template_file='/usr/share/sonic/templates/rsyslog-container.conf.j2'; template = env.get_template(os.path.basename(template_file)); data=template.render({\"target_ip\":\"$TARGET_IP\",\"container_name\":\"$CONTAINER_NAME\"}); print(data)" > $TMP_FILE {%- else %} sonic-cfggen -d -t /usr/share/sonic/templates/rsyslog-container.conf.j2 -a "{\"target_ip\": \"$TARGET_IP\", \"container_name\": \"$CONTAINER_NAME\" }" > $TMP_FILE + if [ $? -ne 0 ]; then + echo "Error: Execute sonic-cfggen -d failed. Execute without '-d'." + sonic-cfggen -t /usr/share/sonic/templates/rsyslog-container.conf.j2 -a "{\"target_ip\": \"$TARGET_IP\", \"container_name\": \"$CONTAINER_NAME\" }" > $TMP_FILE + fi {%- endif %} docker cp $TMP_FILE ${DOCKERNAME}:/etc/rsyslog.conf rm -rf $TMP_FILE diff --git a/files/image_config/rsyslog/rsyslog-container.conf.j2 b/files/image_config/rsyslog/rsyslog-container.conf.j2 index 4e2c90b548..a6419eba84 100644 --- a/files/image_config/rsyslog/rsyslog-container.conf.j2 +++ b/files/image_config/rsyslog/rsyslog-container.conf.j2 @@ -28,9 +28,13 @@ $ModLoad imuxsock # provides support for local system logging {% if rate_limit_interval is defined %} $SystemLogRateLimitInterval {{ rate_limit_interval }} +{% else %} +$SystemLogRateLimitInterval 300 {% endif %} {% if rate_limit_burst is defined %} $SystemLogRateLimitBurst {{ rate_limit_burst }} +{% else %} +$SystemLogRateLimitBurst 20000 {% endif %} #$ModLoad imklog # provides kernel logging support