From 0ffdf4e11942b0d2f90d1cc7ea2a4ee56a3c1d11 Mon Sep 17 00:00:00 2001 From: Zain Budhwani <99770260+zbud-msft@users.noreply.github.com> Date: Tue, 18 Jun 2024 18:13:41 -0700 Subject: [PATCH] Fix rsyslog plugin slim image logic (#19034) * Fix rsyslog plugin slim image logic * Remove asic check for broadcom when checking for eventd enabled and slim image --- dockers/docker-dhcp-relay/Dockerfile.j2 | 4 +--- dockers/docker-fpm-frr/Dockerfile.j2 | 4 +--- dockers/docker-orchagent/Dockerfile.j2 | 4 +--- files/build_templates/init_cfg.json.j2 | 2 +- files/build_templates/sonic_debian_extension.j2 | 4 +--- files/image_config/rsyslog/rsyslog.d/00-sonic.conf.j2 | 11 +++++++---- 6 files changed, 12 insertions(+), 17 deletions(-) diff --git a/dockers/docker-dhcp-relay/Dockerfile.j2 b/dockers/docker-dhcp-relay/Dockerfile.j2 index 48375e214689..5b0dc82c314b 100644 --- a/dockers/docker-dhcp-relay/Dockerfile.j2 +++ b/dockers/docker-dhcp-relay/Dockerfile.j2 @@ -50,8 +50,7 @@ COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] COPY ["critical_processes", "/etc/supervisor"] COPY ["cli", "/cli/"] -{% if include_system_eventd == "y" %} -{% if build_reduce_image_size != "y" or sonic_asic_platform != "broadcom" %} +{% if include_system_eventd == "y" and build_reduce_image_size != "y" %} # Copy regex json and rsyslog_plugin.conf file into rsyslog.d COPY ["*.json", "/etc/rsyslog.d/"] COPY ["files/rsyslog_plugin.conf.j2", "/etc/rsyslog.d/"] @@ -60,6 +59,5 @@ RUN j2 -f json /etc/rsyslog.d/rsyslog_plugin.conf.j2 /etc/rsyslog.d/events_info. RUN rm -f /etc/rsyslog.d/rsyslog_plugin.conf.j2 RUN rm -f /etc/rsyslog.d/events_info.json {% endif %} -{% endif %} ENTRYPOINT ["/usr/bin/docker_init.sh"] diff --git a/dockers/docker-fpm-frr/Dockerfile.j2 b/dockers/docker-fpm-frr/Dockerfile.j2 index b0dc413c8c89..98c4593811f7 100644 --- a/dockers/docker-fpm-frr/Dockerfile.j2 +++ b/dockers/docker-fpm-frr/Dockerfile.j2 @@ -59,14 +59,12 @@ RUN chmod a+x /usr/bin/TSA && \ chmod a+x /usr/bin/TSC && \ chmod a+x /usr/bin/zsocket.sh -{% if include_system_eventd == "y" %} -{% if build_reduce_image_size != "y" or sonic_asic_platform != "broadcom" %} +{% if include_system_eventd == "y" and build_reduce_image_size != "y" %} COPY ["*.json", "/etc/rsyslog.d/"] COPY ["files/rsyslog_plugin.conf.j2", "/etc/rsyslog.d/"] RUN j2 -f json /etc/rsyslog.d/rsyslog_plugin.conf.j2 /etc/rsyslog.d/events_info.json > /etc/rsyslog.d/bgp_events.conf RUN rm -f /etc/rsyslog.d/rsyslog_plugin.conf.j2 RUN rm -f /etc/rsyslog.d/events_info.json {% endif %} -{% endif %} ENTRYPOINT ["/usr/bin/docker_init.sh"] diff --git a/dockers/docker-orchagent/Dockerfile.j2 b/dockers/docker-orchagent/Dockerfile.j2 index 3bc02a9d8fc4..fb90b4f09c22 100755 --- a/dockers/docker-orchagent/Dockerfile.j2 +++ b/dockers/docker-orchagent/Dockerfile.j2 @@ -80,8 +80,7 @@ RUN sonic-cfggen -a "{\"ENABLE_ASAN\":\"{{ENABLE_ASAN}}\"}" -t /usr/share/sonic/ RUN rm -f /usr/share/sonic/templates/docker-init.j2 RUN chmod 755 /usr/bin/docker-init.sh -{% if include_system_eventd == "y" %} -{% if build_reduce_image_size != "y" or sonic_asic_platform != "broadcom" %} +{% if include_system_eventd == "y" and build_reduce_image_size != "y" %} # Copy all regex json files and rsyslog_plugin.conf to rsyslog.d COPY ["*.json", "/etc/rsyslog.d/"] COPY ["files/rsyslog_plugin.conf.j2", "/etc/rsyslog.d/"] @@ -90,6 +89,5 @@ RUN j2 -f json /etc/rsyslog.d/rsyslog_plugin.conf.j2 /etc/rsyslog.d/events_info. RUN rm -f /etc/rsyslog.d/rsyslog_plugin.conf.j2 RUN rm -f /etc/rsyslog.d/events_info.json {% endif %} -{% endif %} ENTRYPOINT ["/usr/bin/docker-init.sh"] diff --git a/files/build_templates/init_cfg.json.j2 b/files/build_templates/init_cfg.json.j2 index 0a185680e690..dc7e4aab7e8e 100644 --- a/files/build_templates/init_cfg.json.j2 +++ b/files/build_templates/init_cfg.json.j2 @@ -61,7 +61,7 @@ {%- if include_macsec == "y" %}{% do features.append(("macsec", "{% if 'type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] == 'SpineRouter' and DEVICE_RUNTIME_METADATA['MACSEC_SUPPORTED'] %}enabled{% else %}disabled{% endif %}", false, "enabled")) %}{% endif %} {%- if include_system_gnmi == "y" %}{% do features.append(("gnmi", "enabled", true, "enabled")) %}{% endif %} {%- if include_system_telemetry == "y" %}{% do features.append(("telemetry", "enabled", true, "enabled")) %}{% endif %} -{%- if include_system_eventd == "y" and BUILD_REDUCE_IMAGE_SIZE == "y" and sonic_asic_platform == "broadcom" %} +{%- if include_system_eventd == "y" and BUILD_REDUCE_IMAGE_SIZE == "y" %} {% do features.append(("eventd","disabled", false, "enabled")) %} {%- elif include_system_eventd == "y" %} {% do features.append(("eventd", "enabled", false, "enabled")) %} diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index ece833119be6..52f12b4ef7c4 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -354,8 +354,7 @@ sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/sonic-db-cli_*.deb || \ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f -{% if include_system_eventd == "y" %} -{% if build_reduce_image_size != "y" or sonic_asic_platform != "broadcom" %} +{% if include_system_eventd == "y" and build_reduce_image_size != "y" %} # Install sonic-rsyslog-plugin sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/sonic-rsyslog-plugin_*.deb || \ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f @@ -375,7 +374,6 @@ sudo cp $BUILD_TEMPLATES/bgpd_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/ j2 -f json $BUILD_TEMPLATES/rsyslog_plugin.conf.j2 $BUILD_TEMPLATES/syncd_events_info.json | sudo tee $FILESYSTEM_ROOT_ETC/rsyslog.d/syncd_events.conf sudo cp $BUILD_TEMPLATES/syncd_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/ -{% endif %} {% endif %} # Install custom-built monit package and SONiC configuration files diff --git a/files/image_config/rsyslog/rsyslog.d/00-sonic.conf.j2 b/files/image_config/rsyslog/rsyslog.d/00-sonic.conf.j2 index 66eb1346362c..a5b4689741dc 100644 --- a/files/image_config/rsyslog/rsyslog.d/00-sonic.conf.j2 +++ b/files/image_config/rsyslog/rsyslog.d/00-sonic.conf.j2 @@ -5,31 +5,34 @@ template(name="prog_msg" type="list") { constant(value="\n") } -{% if include_system_eventd == "y" %} -{% if build_reduce_image_size != "y" or sonic_asic_platform != "broadcom" %} +{% if include_system_eventd == "y" and build_reduce_image_size != "y" %} $ModLoad omprog +{% endif %} + if re_match($programname, "bgp[0-9]*#(frr|zebra|staticd|watchfrr)") then { /var/log/frr/zebra.log + {% if include_system_eventd == "y" and build_reduce_image_size != "y" %} action(type="omprog" binary="/usr/bin/rsyslog_plugin -r /etc/rsyslog.d/zebra_regex.json -m sonic-events-bgp" output="/var/log/rsyslog_plugin.log" template="prog_msg") + {% endif %} stop } if re_match($programname, "bgp[0-9]*#bgpd") then { /var/log/frr/bgpd.log + {% if include_system_eventd == "y" and build_reduce_image_size != "y" %} action(type="omprog" binary="/usr/bin/rsyslog_plugin -r /etc/rsyslog.d/bgpd_regex.json -m sonic-events-bgp" output="/var/log/rsyslog_plugin.log" template="prog_msg") + {% endif %} stop } -{% endif %} -{% endif %} ## Teamd rules