Skip to content

Commit 57c02e3

Browse files
authored
Remove rsyslog plugin from all non eventd containers (sonic-net#21338)
#### Why I did it Fixes Issue sonic-net#21227 - As of current, we have rsyslog_plugin and corresponding regex and configuration files in containers like bgp, swss, dhcp_relay. These binaries and files are built as part of the docker container itself. - This change removes that dependency by storing all rsyslog_plugin regex and conference files in the eventd docker container, and at runtime copying them to the host. - Fixes the issue that some images will not be able to publish certain events like "bgp-state", or "dhcp-relay-discard" due to reuse of docker containers during where eventd was disabled. #### How I did it - Removed all rsyslog plugin configuration and regex files from containers such as bgp, swss, dhcp_relay. All files for configuration and regexes are built inside eventd docker container. When eventd docker is started, it will copy these files to the host and restart rsyslog. - sshd regex and zebra regex are removed because those events are currently not being supported. - Possible race condition with rsyslog-config is avoided due to "After" and since rsyslog-config.service is type oneshot, rsyslog-config.sh is guaranteed to complete before eventd.service is called. #### How to verify it Tested on all elastic pipeline for 6 different HWSKUs Arista-7260CX, Arista720DT, Mellanox2700, Cisco 8102, Nokia M0, Arista 7060CX
1 parent 4c46425 commit 57c02e3

35 files changed

+34
-83
lines changed

dockers/docker-config-engine-bookworm/00-load-omprog.conf

-1
This file was deleted.

dockers/docker-config-engine-bookworm/Dockerfile.j2

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ RUN pip3 install redis==5.0.1
4747
COPY ["files/swss_vars.j2", "/usr/share/sonic/templates/"]
4848
COPY ["files/readiness_probe.sh", "/usr/bin/"]
4949
COPY ["files/container_startup.py", "/usr/share/sonic/scripts/"]
50-
COPY ["00-load-omprog.conf", "/etc/rsyslog.d/"]
5150

5251
## Clean up
5352
RUN apt-get purge -y \

dockers/docker-config-engine-bullseye/00-load-omprog.conf

-1
This file was deleted.

dockers/docker-config-engine-bullseye/Dockerfile.j2

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ RUN pip3 install redis==4.5.4
5050
COPY ["files/swss_vars.j2", "/usr/share/sonic/templates/"]
5151
COPY ["files/readiness_probe.sh", "/usr/bin/"]
5252
COPY ["files/container_startup.py", "/usr/share/sonic/scripts/"]
53-
COPY ["00-load-omprog.conf", "/etc/rsyslog.d/"]
5453

5554
## Clean up
5655
RUN apt-get purge -y \

dockers/docker-dhcp-relay/Dockerfile.j2

-10
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,4 @@ COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
5050
COPY ["critical_processes", "/etc/supervisor"]
5151
COPY ["cli", "/cli/"]
5252

53-
{% if include_system_eventd == "y" and build_reduce_image_size != "y" %}
54-
# Copy regex json and rsyslog_plugin.conf file into rsyslog.d
55-
COPY ["*.json", "/etc/rsyslog.d/"]
56-
COPY ["files/rsyslog_plugin.conf.j2", "/etc/rsyslog.d/"]
57-
# Create dhcp_relay_regex.conf
58-
RUN j2 -f json /etc/rsyslog.d/rsyslog_plugin.conf.j2 /etc/rsyslog.d/events_info.json > /etc/rsyslog.d/dhcp_relay_events.conf
59-
RUN rm -f /etc/rsyslog.d/rsyslog_plugin.conf.j2
60-
RUN rm -f /etc/rsyslog.d/events_info.json
61-
{% endif %}
62-
6353
ENTRYPOINT ["/usr/bin/docker_init.sh"]

dockers/docker-eventd/Dockerfile.j2

+18
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,27 @@ RUN apt-get clean -y && \
2828
apt-get autoremove -y && \
2929
rm -rf /debs
3030

31+
RUN mkdir -p /etc/rsyslog.d/rsyslog_plugin_conf
32+
3133
COPY ["start.sh", "/usr/bin/"]
3234
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
3335
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
3436
COPY ["critical_processes", "/etc/supervisor"]
37+
COPY ["*.json", "/etc/rsyslog.d/rsyslog_plugin_conf/"]
38+
COPY ["files/rsyslog_plugin.conf.j2", "/etc/rsyslog.d/rsyslog_plugin_conf/"]
39+
40+
RUN j2 -f json /etc/rsyslog.d/rsyslog_plugin_conf/rsyslog_plugin.conf.j2 /etc/rsyslog.d/rsyslog_plugin_conf/host_events_info.json > /etc/rsyslog.d/rsyslog_plugin_conf/host_events.conf
41+
RUN j2 -f json /etc/rsyslog.d/rsyslog_plugin_conf/rsyslog_plugin.conf.j2 /etc/rsyslog.d/rsyslog_plugin_conf/bgp_events_info.json > /etc/rsyslog.d/rsyslog_plugin_conf/bgp_events.conf
42+
RUN j2 -f json /etc/rsyslog.d/rsyslog_plugin_conf/rsyslog_plugin.conf.j2 /etc/rsyslog.d/rsyslog_plugin_conf/dhcp_relay_events_info.json > /etc/rsyslog.d/rsyslog_plugin_conf/dhcp_relay_events.conf
43+
RUN j2 -f json /etc/rsyslog.d/rsyslog_plugin_conf/rsyslog_plugin.conf.j2 /etc/rsyslog.d/rsyslog_plugin_conf/swss_events_info.json > /etc/rsyslog.d/rsyslog_plugin_conf/swss_events.conf
44+
RUN j2 -f json /etc/rsyslog.d/rsyslog_plugin_conf/rsyslog_plugin.conf.j2 /etc/rsyslog.d/rsyslog_plugin_conf/syncd_events_info.json > /etc/rsyslog.d/rsyslog_plugin_conf/syncd_events.conf
45+
46+
47+
RUN rm -f /etc/rsyslog.d/rsyslog_plugin_conf/rsyslog_plugin.conf.j2
48+
RUN rm -f /etc/rsyslog.d/rsyslog_plugin_conf/host_events_info.json
49+
RUN rm -f /etc/rsyslog.d/rsyslog_plugin_conf/bgp_events_info.json
50+
RUN rm -f /etc/rsyslog.d/rsyslog_plugin_conf/dhcp_relay_events_info.json
51+
RUN rm -f /etc/rsyslog.d/rsyslog_plugin_conf/swss_events_info.json
52+
RUN rm -f /etc/rsyslog.d/rsyslog_plugin_conf/syncd_events_info.json
3553

3654
ENTRYPOINT ["/usr/local/bin/supervisord"]
File renamed without changes.
File renamed without changes.

files/build_templates/events_info.json dockers/docker-eventd/host_events_info.json

-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
"name": "monit",
66
"parse_json": "monit_regex.json"
77
},
8-
{
9-
"name": "sshd",
10-
"parse_json": "sshd_regex.json"
11-
},
128
{
139
"name": "systemd",
1410
"parse_json": "systemd_regex.json"
File renamed without changes.
File renamed without changes.

dockers/docker-eventd/start.sh

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
if [ "${RUNTIME_OWNER}" == "" ]; then
44
RUNTIME_OWNER="kube"
55
fi
6-
File renamed without changes.
File renamed without changes.

dockers/docker-fpm-frr/Dockerfile.j2

-8
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,4 @@ RUN chmod a+x /usr/bin/TSA && \
5959
chmod a+x /usr/bin/TSC && \
6060
chmod a+x /usr/bin/zsocket.sh
6161

62-
{% if include_system_eventd == "y" and build_reduce_image_size != "y" %}
63-
COPY ["*.json", "/etc/rsyslog.d/"]
64-
COPY ["files/rsyslog_plugin.conf.j2", "/etc/rsyslog.d/"]
65-
RUN j2 -f json /etc/rsyslog.d/rsyslog_plugin.conf.j2 /etc/rsyslog.d/events_info.json > /etc/rsyslog.d/bgp_events.conf
66-
RUN rm -f /etc/rsyslog.d/rsyslog_plugin.conf.j2
67-
RUN rm -f /etc/rsyslog.d/events_info.json
68-
{% endif %}
69-
7062
ENTRYPOINT ["/usr/bin/docker_init.sh"]

dockers/docker-orchagent/Dockerfile.j2

-10
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,4 @@ RUN sonic-cfggen -a "{\"ENABLE_ASAN\":\"{{ENABLE_ASAN}}\"}" -t /usr/share/sonic/
8080
RUN rm -f /usr/share/sonic/templates/docker-init.j2
8181
RUN chmod 755 /usr/bin/docker-init.sh
8282

83-
{% if include_system_eventd == "y" and build_reduce_image_size != "y" %}
84-
# Copy all regex json files and rsyslog_plugin.conf to rsyslog.d
85-
COPY ["*.json", "/etc/rsyslog.d/"]
86-
COPY ["files/rsyslog_plugin.conf.j2", "/etc/rsyslog.d/"]
87-
# Create swss rsyslog_plugin conf file
88-
RUN j2 -f json /etc/rsyslog.d/rsyslog_plugin.conf.j2 /etc/rsyslog.d/events_info.json > /etc/rsyslog.d/swss_events.conf
89-
RUN rm -f /etc/rsyslog.d/rsyslog_plugin.conf.j2
90-
RUN rm -f /etc/rsyslog.d/events_info.json
91-
{% endif %}
92-
9383
ENTRYPOINT ["/usr/bin/docker-init.sh"]

files/build_templates/docker_image_ctl.j2

+7
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,13 @@ function postStartAction()
339339
docker cp $PSENSOR pmon:/usr/bin/
340340
fi
341341
fi
342+
{%- elif docker_container_name == "eventd" %}
343+
HOST_RSYSLOG_PLUGIN_CONF_FILE="/etc/rsyslog.d/host_events.conf"
344+
if [ ! -f ${HOST_RSYSLOG_PLUGIN_CONF_FILE} ]; then
345+
for f in $(docker exec -i eventd ls /etc/rsyslog.d/rsyslog_plugin_conf); do docker cp eventd:/etc/rsyslog.d/rsyslog_plugin_conf/$f /etc/rsyslog.d/; done
346+
systemctl reset-failed rsyslog
347+
systemctl restart rsyslog
348+
fi
342349
{%- else %}
343350
: # nothing
344351
{%- endif %}

files/build_templates/eventd.service.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[Unit]
22
Description=EVENTD container
33
Requires=config-setup.service
4-
After=config-setup.service
4+
After=rsyslog-config.service
55
BindsTo=sonic.target
66
After=sonic.target
77
StartLimitIntervalSec=1200

files/build_templates/sonic_debian_extension.j2

-16
Original file line numberDiff line numberDiff line change
@@ -367,22 +367,6 @@ sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/sonic-db-cli_*.deb || \
367367
# Install sonic-rsyslog-plugin
368368
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/sonic-rsyslog-plugin_*.deb || \
369369
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
370-
371-
# Generate host conf for rsyslog_plugin
372-
j2 -f json $BUILD_TEMPLATES/rsyslog_plugin.conf.j2 $BUILD_TEMPLATES/events_info.json | sudo tee $FILESYSTEM_ROOT_ETC/rsyslog.d/host_events.conf
373-
sudo cp $BUILD_TEMPLATES/monit_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/
374-
sudo cp $BUILD_TEMPLATES/sshd_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/
375-
sudo cp $BUILD_TEMPLATES/systemd_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/
376-
sudo cp $BUILD_TEMPLATES/kernel_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/
377-
sudo cp $BUILD_TEMPLATES/dockerd_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/
378-
sudo cp $BUILD_TEMPLATES/seu_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/
379-
sudo cp $BUILD_TEMPLATES/zebra_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/
380-
sudo cp $BUILD_TEMPLATES/bgpd_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/
381-
382-
383-
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
384-
sudo cp $BUILD_TEMPLATES/syncd_regex.json $FILESYSTEM_ROOT_ETC/rsyslog.d/
385-
386370
{% endif %}
387371

388372
# Install custom-built monit package and SONiC configuration files

files/build_templates/sshd_regex.json

-7
This file was deleted.

files/build_templates/zebra_regex.json

-7
This file was deleted.

files/image_config/rsyslog/rsyslog.d/00-sonic.conf.j2

-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ $ModLoad omprog
1313

1414
if re_match($programname, "bgp[0-9]*#(frr|zebra|staticd|watchfrr)") then {
1515
/var/log/frr/zebra.log
16-
{% if include_system_eventd == "y" and build_reduce_image_size != "y" %}
17-
action(type="omprog"
18-
binary="/usr/bin/rsyslog_plugin -r /etc/rsyslog.d/zebra_regex.json -m sonic-events-bgp"
19-
output="/var/log/rsyslog_plugin.log"
20-
template="prog_msg")
21-
{% endif %}
2216
stop
2317
}
2418

rules/docker-dhcp-relay.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ DOCKER_DHCP_RELAY_DBG = $(DOCKER_DHCP_RELAY_STEM)-$(DBG_IMAGE_MARK).gz
66

77
$(DOCKER_DHCP_RELAY)_PATH = $(DOCKERS_PATH)/$(DOCKER_DHCP_RELAY_STEM)
88

9-
$(DOCKER_DHCP_RELAY)_DEPENDS += $(ISC_DHCP_RELAY) $(SONIC_DHCPMON) $(SONIC_DHCPRELAY) $(LIBSWSSCOMMON) $(SONIC_RSYSLOG_PLUGIN)
9+
$(DOCKER_DHCP_RELAY)_DEPENDS += $(ISC_DHCP_RELAY) $(SONIC_DHCPMON) $(SONIC_DHCPRELAY) $(LIBSWSSCOMMON)
1010

1111
$(DOCKER_DHCP_RELAY)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BOOKWORM)_DBG_DEPENDS)
12-
$(DOCKER_DHCP_RELAY)_DBG_DEPENDS += $(ISC_DHCP_RELAY_DBG) $(SONIC_DHCPRELAY_DBG) $(SONIC_DHCPMON_DBG) $(SONIC_RSYSLOG_PLUGIN)
12+
$(DOCKER_DHCP_RELAY)_DBG_DEPENDS += $(ISC_DHCP_RELAY_DBG) $(SONIC_DHCPRELAY_DBG) $(SONIC_DHCPMON_DBG)
1313

1414
$(DOCKER_DHCP_RELAY)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BOOKWORM)_DBG_IMAGE_PACKAGES)
1515

rules/docker-dhcp-server.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ DOCKER_DHCP_SERVER_DBG = $(DOCKER_DHCP_SERVER_STEM)-$(DBG_IMAGE_MARK).gz
66

77
$(DOCKER_DHCP_SERVER)_PATH = $(DOCKERS_PATH)/$(DOCKER_DHCP_SERVER_STEM)
88

9-
$(DOCKER_DHCP_SERVER)_DEPENDS = $(LIBSWSSCOMMON) $(SONIC_RSYSLOG_PLUGIN)
9+
$(DOCKER_DHCP_SERVER)_DEPENDS = $(LIBSWSSCOMMON)
1010
$(DOCKER_DHCP_SERVER)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BOOKWORM)_DBG_DEPENDS)
1111

1212
$(DOCKER_DHCP_SERVER)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BOOKWORM)_DBG_IMAGE_PACKAGES)

rules/docker-eventd.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ $(DOCKER_EVENTD)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)
3535
$(DOCKER_EVENTD)_CONTAINER_NAME = eventd
3636
$(DOCKER_EVENTD)_RUN_OPT += -t
3737
$(DOCKER_EVENTD)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
38-
$(DOCKER_EVENTD)_RUN_OPT += -v /etc/localtime:/etc/localtime:ro
38+
$(DOCKER_EVENTD)_RUN_OPT += -v /etc/localtime:/etc/localtime:ro
3939

4040
SONIC_BOOKWORM_DOCKERS += $(DOCKER_EVENTD)
4141
SONIC_BOOKWORM_DBG_DOCKERS += $(DOCKER_EVENTD_DBG)

rules/docker-fpm-frr.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ DOCKER_FPM_FRR_DBG = $(DOCKER_FPM_FRR_STEM)-$(DBG_IMAGE_MARK).gz
77
$(DOCKER_FPM_FRR)_PATH = $(DOCKERS_PATH)/$(DOCKER_FPM_FRR_STEM)
88
$(DOCKER_FPM_FRR)_PYTHON_WHEELS += $(SONIC_BGPCFGD) $(SONIC_FRR_MGMT_FRAMEWORK)
99

10-
$(DOCKER_FPM_FRR)_DEPENDS += $(FRR) $(FRR_SNMP) $(SWSS) $(LIBYANG2) $(SONIC_RSYSLOG_PLUGIN)
10+
$(DOCKER_FPM_FRR)_DEPENDS += $(FRR) $(FRR_SNMP) $(SWSS) $(LIBYANG2)
1111
$(DOCKER_FPM_FRR)_DBG_DEPENDS = $($(DOCKER_SWSS_LAYER_BOOKWORM)_DBG_DEPENDS)
1212
$(DOCKER_FPM_FRR)_DBG_DEPENDS += $(SWSS_DBG) $(LIBSWSSCOMMON_DBG) \
13-
$(FRR_DBG) $(FRR_SNMP_DBG) $(LIBYANG2_DBG) $(SONIC_RSYSLOG_PLUGIN)
13+
$(FRR_DBG) $(FRR_SNMP_DBG) $(LIBYANG2_DBG)
1414

1515
$(DOCKER_FPM_FRR)_DBG_IMAGE_PACKAGES = $($(DOCKER_SWSS_LAYER_BOOKWORM)_DBG_IMAGE_PACKAGES)
1616

rules/docker-orchagent.mk

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ DOCKER_ORCHAGENT_STEM = docker-orchagent
44
DOCKER_ORCHAGENT = $(DOCKER_ORCHAGENT_STEM).gz
55
DOCKER_ORCHAGENT_DBG = $(DOCKER_ORCHAGENT_STEM)-$(DBG_IMAGE_MARK).gz
66

7-
$(DOCKER_ORCHAGENT)_DEPENDS += $(SWSS) $(SONIC_RSYSLOG_PLUGIN) $(LIB_SONIC_DASH_API)
7+
$(DOCKER_ORCHAGENT)_DEPENDS += $(SWSS) $(LIB_SONIC_DASH_API)
88

99
ifeq ($(ENABLE_ASAN), y)
1010
$(DOCKER_ORCHAGENT)_DEPENDS += $(SWSS_DBG)
@@ -13,8 +13,7 @@ endif
1313
$(DOCKER_ORCHAGENT)_DBG_DEPENDS = $($(DOCKER_SWSS_LAYER_BOOKWORM)_DBG_DEPENDS)
1414
$(DOCKER_ORCHAGENT)_DBG_DEPENDS += $(SWSS_DBG) \
1515
$(LIBSWSSCOMMON_DBG) \
16-
$(LIBSAIREDIS_DBG) \
17-
$(SONIC_RSYSLOG_PLUGIN)
16+
$(LIBSAIREDIS_DBG)
1817
$(DOCKER_ORCHAGENT)_PYTHON_WHEELS += $(SCAPY)
1918

2019
$(DOCKER_ORCHAGENT)_DBG_IMAGE_PACKAGES = $($(DOCKER_SWSS_LAYER_BOOKWORM)_DBG_IMAGE_PACKAGES)

0 commit comments

Comments
 (0)