Skip to content

Commit

Permalink
[Services] Restart BGP service upon unexpected critical process exit. (
Browse files Browse the repository at this point in the history
  • Loading branch information
yozhao101 authored and rlhui committed Mar 4, 2020
1 parent c495dc3 commit 5c8c4b2
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 4 deletions.
1 change: 0 additions & 1 deletion dockers/docker-database/supervisord.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected


[program:rsyslogd]
command=/bin/bash -c "rm -f /var/run/rsyslogd.pid && /usr/sbin/rsyslogd -n"
priority=1
Expand Down
2 changes: 2 additions & 0 deletions dockers/docker-fpm-frr/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ COPY ["snmp.conf", "/etc/snmp/frr.conf"]
COPY ["TSA", "/usr/bin/TSA"]
COPY ["TSB", "/usr/bin/TSB"]
COPY ["TSC", "/usr/bin/TSC"]
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
COPY ["critical_processes", "/etc/supervisor"]
RUN chmod a+x /usr/bin/TSA && \
chmod a+x /usr/bin/TSB && \
chmod a+x /usr/bin/TSC
Expand Down
5 changes: 5 additions & 0 deletions dockers/docker-fpm-frr/critical_processes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
zebra
staticd
bgpd
fpmsyncd
bgpcfgd
8 changes: 7 additions & 1 deletion dockers/docker-fpm-frr/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ logfile_maxbytes=1MB
logfile_backups=2
nodaemon=true

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name bgp
events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected

[program:start.sh]
command=/usr/bin/start.sh
priority=1
Expand All @@ -25,7 +31,7 @@ stderr_logfile=syslog
command=/usr/sbin/rsyslogd -n
priority=3
autostart=false
autorestart=false
autorestart=unexpected
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
Expand Down
2 changes: 2 additions & 0 deletions dockers/docker-fpm-gobgp/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ COPY ["start.sh", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["*.j2", "/usr/share/sonic/templates/"]
COPY ["daemons", "/etc/quagga/"]
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
COPY ["critical_processes", "/etc/supervisor"]

ENTRYPOINT ["/usr/bin/supervisord"]
2 changes: 2 additions & 0 deletions dockers/docker-fpm-gobgp/critical_processes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
gobgpd
fpmsyncd
8 changes: 7 additions & 1 deletion dockers/docker-fpm-gobgp/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ logfile_maxbytes=1MB
logfile_backups=2
nodaemon=true

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name bgp
events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected

[program:start.sh]
command=/usr/bin/start.sh
priority=1
Expand All @@ -15,7 +21,7 @@ stderr_logfile=syslog
command=/usr/sbin/rsyslogd -n
priority=2
autostart=false
autorestart=false
autorestart=unexpected
stdout_logfile=syslog
stderr_logfile=syslog

Expand Down
2 changes: 2 additions & 0 deletions dockers/docker-fpm-quagga/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ RUN rm -rf /debs ~/.cache
COPY ["bgpcfgd", "start.sh", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["*.j2", "/usr/share/sonic/templates/"]
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
COPY ["critical_processes", "/etc/supervisor"]

ENTRYPOINT ["/usr/bin/supervisord"]
4 changes: 4 additions & 0 deletions dockers/docker-fpm-quagga/critical_processes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
zebra
bgpd
fpmsyncd
bgpcfgd
8 changes: 7 additions & 1 deletion dockers/docker-fpm-quagga/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ logfile_maxbytes=1MB
logfile_backups=2
nodaemon=true

[eventlistener:supervisor-proc-exit-listener]
command=/usr/bin/supervisor-proc-exit-listener --container-name bgp
events=PROCESS_STATE_EXITED
autostart=true
autorestart=unexpected

[program:start.sh]
command=/usr/bin/start.sh
priority=1
Expand All @@ -25,7 +31,7 @@ stderr_logfile=syslog
command=/usr/sbin/rsyslogd -n
priority=3
autostart=false
autorestart=false
autorestart=unexpected
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
Expand Down
4 changes: 4 additions & 0 deletions files/build_templates/single_instance/bgp.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ Description=BGP container
Requires=updategraph.service
After=updategraph.service
Before=ntp-config.service
StartLimitIntervalSec=1200
StartLimitBurst=3

[Service]
User={{ sonicadmin_user }}
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
ExecStart=/usr/bin/{{docker_container_name}}.sh wait
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
Restart=always
RestartSec=30

[Install]
WantedBy=multi-user.target
2 changes: 2 additions & 0 deletions rules/docker-fpm-frr.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ $(DOCKER_FPM_FRR)_RUN_OPT += --privileged -t
$(DOCKER_FPM_FRR)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
$(DOCKER_FPM_FRR)_RUN_OPT += -v /etc/sonic/frr:/etc/frr:rw

$(DOCKER_FPM_FRR)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)

$(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += vtysh:/usr/bin/vtysh
$(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += TSA:/usr/bin/TSA
$(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += TSB:/usr/bin/TSB
Expand Down
1 change: 1 addition & 0 deletions rules/docker-fpm-gobgp.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ SONIC_DOCKER_IMAGES += $(DOCKER_FPM_GOBGP)
$(DOCKER_FPM_GOBGP)_CONTAINER_NAME = bgp
$(DOCKER_FPM_GOBGP)_RUN_OPT += --privileged -t
$(DOCKER_FPM_GOBGP)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
$(DOCKER_FPM_GOBPG)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)
2 changes: 2 additions & 0 deletions rules/docker-fpm-quagga.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ $(DOCKER_FPM_QUAGGA)_CONTAINER_NAME = bgp
$(DOCKER_FPM_QUAGGA)_RUN_OPT += --privileged -t
$(DOCKER_FPM_QUAGGA)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro

$(DOCKER_FPM_QUAGGA)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)

$(DOCKER_FPM_QUAGGA)_BASE_IMAGE_FILES += vtysh:/usr/bin/vtysh

0 comments on commit 5c8c4b2

Please sign in to comment.