From 7d69ae199f223ead9ad6ade3d8ec2876767a5bcb Mon Sep 17 00:00:00 2001 From: Zain Budhwani Date: Wed, 22 May 2024 00:01:07 +0000 Subject: [PATCH 1/3] Fix rsyslog plugin slim image logic --- .../image_config/rsyslog/rsyslog.d/00-sonic.conf.j2 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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..c2a51b5fe1ad 100644 --- a/files/image_config/rsyslog/rsyslog.d/00-sonic.conf.j2 +++ b/files/image_config/rsyslog/rsyslog.d/00-sonic.conf.j2 @@ -10,26 +10,35 @@ template(name="prog_msg" type="list") { $ModLoad omprog +{% endif %} +{% endif %} + if re_match($programname, "bgp[0-9]*#(frr|zebra|staticd|watchfrr)") then { /var/log/frr/zebra.log + {% if include_system_eventd == "y" %} + {% if build_reduce_image_size != "y" or sonic_asic_platform != "broadcom" %} 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 %} + {% endif %} stop } if re_match($programname, "bgp[0-9]*#bgpd") then { /var/log/frr/bgpd.log + {% if include_system_eventd == "y" %} + {% if build_reduce_image_size != "y" or sonic_asic_platform != "broadcom" %} 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 %} + {% endif %} stop } -{% endif %} -{% endif %} ## Teamd rules From 7b0a03fcbedb86b244332c60fc8962cd3cb342cd Mon Sep 17 00:00:00 2001 From: Zain Budhwani Date: Wed, 5 Jun 2024 18:14:12 +0000 Subject: [PATCH 2/3] 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 +--- .../image_config/rsyslog/rsyslog.d/00-sonic.conf.j2 | 12 +++--------- 6 files changed, 8 insertions(+), 22 deletions(-) diff --git a/dockers/docker-dhcp-relay/Dockerfile.j2 b/dockers/docker-dhcp-relay/Dockerfile.j2 index 9d0614ce4ae1..d054fdc92f44 100644 --- a/dockers/docker-dhcp-relay/Dockerfile.j2 +++ b/dockers/docker-dhcp-relay/Dockerfile.j2 @@ -52,8 +52,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/"] @@ -62,6 +61,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 d0cb32d02ec5..9548b5fa5c60 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 if 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 ae382263bb18..5dc8d6ee3dc7 100644 --- a/files/build_templates/init_cfg.json.j2 +++ b/files/build_templates/init_cfg.json.j2 @@ -59,7 +59,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 74865bf571e0..e80b93e32745 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 c2a51b5fe1ad..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,37 +5,31 @@ 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 %} {% endif %} if re_match($programname, "bgp[0-9]*#(frr|zebra|staticd|watchfrr)") then { /var/log/frr/zebra.log - {% 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" %} 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 %} - {% endif %} stop } if re_match($programname, "bgp[0-9]*#bgpd") then { /var/log/frr/bgpd.log - {% 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" %} 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 %} - {% endif %} stop } From db663a641d36f96867afb1ca9c0c45d1b4f2fd40 Mon Sep 17 00:00:00 2001 From: Zain Budhwani Date: Wed, 5 Jun 2024 18:15:59 +0000 Subject: [PATCH 3/3] Remove if --- dockers/docker-fpm-frr/Dockerfile.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockers/docker-fpm-frr/Dockerfile.j2 b/dockers/docker-fpm-frr/Dockerfile.j2 index 9548b5fa5c60..ac536989ad50 100644 --- a/dockers/docker-fpm-frr/Dockerfile.j2 +++ b/dockers/docker-fpm-frr/Dockerfile.j2 @@ -59,7 +59,7 @@ 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" and if build_reduce_image_size != "y" %} +{% 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