Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dockers]: use supervisord dependent startup to start services #4599

Merged
merged 25 commits into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8a2db49
[docker-base]: add supervisord-dependent-startup plugin for supervisord
lguohan May 14, 2020
cb9e091
[docker-base]: remove dummy password for supervisord control
lguohan May 14, 2020
432474a
[docker-frr]: use service dependency in supervisord to start services
lguohan May 14, 2020
b120328
[docker-nat]: use service dependency in supervisord to start servicesx
lguohan May 14, 2020
3ba3b8c
[docker-iccpd]: use service dependency in supervisord to start services
lguohan May 14, 2020
e818e07
[docker-lldp-sv2]: use service dependency in supervisord to start ser…
lguohan May 15, 2020
bc7fda9
[docker-radvd]: use service dependency in supervisord to start services
lguohan May 15, 2020
e7a9d4b
[docker-orchagent]: use service dependency in supervisord to start se…
lguohan May 16, 2020
1a6004a
[docker-sflow]: use service dependency in supervisord to start services
lguohan May 16, 2020
820c57b
[docker-pmon]: use service dependency in supervisord to start services
lguohan May 16, 2020
a571cb8
[docker-restapi]: use service dependency in supervisord to start serv…
lguohan May 16, 2020
fb9e504
[docker-telemetry]: use service dependency in supervisord to start se…
lguohan May 16, 2020
50ffd76
[docker-mgmt-framework]: use service dependency in supervisord to sta…
lguohan May 16, 2020
4e7709a
[docker-teamd]: use service dependency in supervisord to start services
lguohan May 16, 2020
530f84e
[docker-dhcp-relay]: use service dependency in supervisord to start s…
lguohan May 16, 2020
8f6476f
[docker-syncd-vs]: use service dependency in supervisord to start ser…
lguohan May 16, 2020
e7b43fd
[docker-syncd-brcm]: use service dependency in supervisord to start s…
lguohan May 16, 2020
5d85ee7
[docker-syncd-mlnx]: use service dependency in supervisord to start s…
lguohan May 16, 2020
63bde63
[docker-syncd-bfn]: use service dependency in supervisord to start se…
lguohan May 16, 2020
850bf82
[docker-syncd-invm]: use service dependency in supervisord to start s…
lguohan May 16, 2020
0f54215
[docker-syncd-centec]: use service dependency in supervisord to start…
lguohan May 16, 2020
d357979
[docker-syncd-mrvl]: use service dependency in supervisord to start s…
lguohan May 16, 2020
5d9dcb1
[docker-syncd-nephos]: use service dependency in supervisord to start…
lguohan May 16, 2020
76f9a2f
[docker-snmp-sv2]: use service dependency in supervisord to start ser…
lguohan May 16, 2020
14c7139
[docker-database]: do not generate pidfile for rsyslogd
lguohan May 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dockers/docker-base-buster/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ RUN apt-get -y purge \
{{ install_debian_packages(docker_base_buster_debs.split(' ')) }}
{%- endif %}

# Add support for supervisord to handle startup dependencies
RUN pip install supervisord-dependent-startup==1.4.0

# Clean up apt
# Remove /var/lib/apt/lists/*, could be obsoleted for derived images
RUN apt-get clean -y && \
Expand Down
4 changes: 0 additions & 4 deletions dockers/docker-base-buster/etc/supervisor/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0700 ; socket file mode (default 0700)
username=dummy
password=dummy
lguohan marked this conversation as resolved.
Show resolved Hide resolved

[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
Expand All @@ -20,8 +18,6 @@ supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
username=dummy
password=dummy

; The [include] section can just contain the "files" setting. This
; setting can list multiple files (separated by whitespace or
Expand Down
3 changes: 3 additions & 0 deletions dockers/docker-base-stretch/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ RUN apt-get -y purge \
{{ install_debian_packages(docker_base_stretch_debs.split(' ')) }}
{%- endif %}

# Add support for supervisord to handle startup dependencies
RUN pip install supervisord-dependent-startup==1.4.0

# Clean up apt
# Remove /var/lib/apt/lists/*, could be obsoleted for derived images
RUN apt-get clean -y && \
Expand Down
4 changes: 0 additions & 4 deletions dockers/docker-base-stretch/etc/supervisor/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0700 ; socket file mode (default 0700)
username=dummy
password=dummy

[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
Expand All @@ -20,8 +18,6 @@ supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
username=dummy
password=dummy

; The [include] section can just contain the "files" setting. This
; setting can list multiple files (separated by whitespace or
Expand Down
2 changes: 1 addition & 1 deletion dockers/docker-database/supervisord.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ autostart=true
autorestart=unexpected

[program:rsyslogd]
command=/bin/bash -c "rm -f /var/run/rsyslogd.pid && /usr/sbin/rsyslogd -n"
command=/usr/sbin/rsyslogd -n -iNONE
priority=1
autostart=true
autorestart=false
Expand Down
26 changes: 21 additions & 5 deletions dockers/docker-dhcp-relay/docker-dhcp-relay.supervisord.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,39 @@ logfile_maxbytes=1MB
logfile_backups=2
nodaemon=true

[eventlistener:dependent-startup]
command=python -m supervisord_dependent_startup
autostart=true
autorestart=unexpected
startretries=0
exitcodes=0,3
events=PROCESS_STATE

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

[program:start.sh]
command=/usr/bin/start.sh
[program:rsyslogd]
command=/usr/sbin/rsyslogd -n -iNONE
priority=1
autostart=true
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true

[program:rsyslogd]
command=/usr/sbin/rsyslogd -n
[program:start]
command=/usr/bin/start.sh
priority=2
autostart=false
autorestart=false
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=rsyslogd:running

{# If our configuration has VLANs... #}
{% if VLAN %}
Expand Down Expand Up @@ -81,6 +93,8 @@ autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=start:exited

{% endif %}
{% endif %}
Expand Down Expand Up @@ -128,6 +142,8 @@ autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=isc-dhcp-relay-{{ vlan_name }}:running

{% endif %}
{% endif %}
Expand Down
15 changes: 0 additions & 15 deletions dockers/docker-dhcp-relay/start.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#!/usr/bin/env bash

# Remove stale rsyslog PID file if it exists
rm -f /var/run/rsyslogd.pid

# Start rsyslog
supervisorctl start rsyslogd

# If our supervisor config has entries in the "isc-dhcp-relay" group...
if [ $(supervisorctl status | grep -c "^isc-dhcp-relay:") -gt 0 ]; then
# Wait for all interfaces to come up and be assigned IPv4 addresses before
Expand All @@ -15,13 +9,4 @@ if [ $(supervisorctl status | grep -c "^isc-dhcp-relay:") -gt 0 ]; then
# relay agent starts, it will not listen or send on that interface for the
# lifetime of the process.
/usr/bin/wait_for_intf.sh

# Start all DHCP relay agent(s)
supervisorctl start isc-dhcp-relay:*
fi

# If our supervisor config has entries in the "dhcpmon" group...
if [ $(supervisorctl status | grep -c "^dhcpmon:") -gt 0 ]; then
# Start all DHCP Monitor daemon(s)
supervisorctl start dhcpmon:*
fi
5 changes: 2 additions & 3 deletions dockers/docker-fpm-frr/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ RUN apt-get clean -y && \
rm -rf /debs ~/.cache

COPY ["frr", "/usr/share/sonic/templates"]
COPY ["bgpcfgd", "start.sh", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["bgpcfgd", "docker_init.sh", "/usr/bin/"]
COPY ["snmp.conf", "/etc/snmp/frr.conf"]
COPY ["TSA", "/usr/bin/TSA"]
COPY ["TSB", "/usr/bin/TSB"]
Expand All @@ -52,4 +51,4 @@ RUN chmod a+x /usr/bin/TSA && \
chmod a+x /usr/bin/TSB && \
chmod a+x /usr/bin/TSC

ENTRYPOINT ["/usr/bin/supervisord"]
ENTRYPOINT ["/usr/bin/docker_init.sh"]
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env bash

mkdir -p /etc/frr
mkdir -p /etc/supervisor/conf.d

CONFIG_TYPE=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["docker_routing_config_mode"]'`
sonic-cfggen -d -t /usr/share/sonic/templates/supervisord/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf

CONFIG_TYPE=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["docker_routing_config_mode"]'`
if [ -z "$CONFIG_TYPE" ] || [ "$CONFIG_TYPE" == "separated" ]; then
lguohan marked this conversation as resolved.
Show resolved Hide resolved
sonic-cfggen -d -t /usr/share/sonic/templates/bgpd/bgpd.conf.j2 -y /etc/sonic/constants.yml > /etc/frr/bgpd.conf
sonic-cfggen -d -t /usr/share/sonic/templates/zebra/zebra.conf.j2 > /etc/frr/zebra.conf
Expand All @@ -29,24 +31,4 @@ chmod 0755 /usr/sbin/bgp-unisolate
mkdir -p /var/sonic
echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status

rm -f /var/run/rsyslogd.pid

supervisorctl start rsyslogd

# start eoiu pulling, only if configured so
if [[ $(sonic-cfggen -d -v 'WARM_RESTART.bgp.bgp_eoiu') == 'true' ]]; then
supervisorctl start bgp_eoiu_marker
fi

# Start Quagga processes
supervisorctl start zebra
supervisorctl start staticd
supervisorctl start bgpd

if [ "$CONFIG_TYPE" == "unified" ]; then
supervisorctl start vtysh_b
fi

supervisorctl start fpmsyncd

supervisorctl start bgpcfgd
exec /usr/bin/supervisord
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,29 @@ logfile_maxbytes=1MB
logfile_backups=2
nodaemon=true

[eventlistener:dependent-startup]
command=python -m supervisord_dependent_startup
autostart=true
autorestart=unexpected
startretries=0
exitcodes=0,3
events=PROCESS_STATE

[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
autostart=true
autorestart=false
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog

[program:bgpcfgd]
command=/usr/bin/bgpcfgd
priority=2
autostart=false
autorestart=false
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog

[program:rsyslogd]
command=/usr/sbin/rsyslogd -n
priority=3
command=/usr/sbin/rsyslogd -n -iNONE
priority=1
autostart=false
autorestart=unexpected
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true

[program:zebra]
command=/usr/lib/frr/zebra -A 127.0.0.1 -s 90000000 -M fpm -M snmp
Expand All @@ -44,6 +35,8 @@ autorestart=false
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=rsyslogd:running

[program:staticd]
command=/usr/lib/frr/staticd -A 127.0.0.1
Expand All @@ -53,6 +46,8 @@ autorestart=false
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=rsyslogd:running

[program:bgpd]
command=/usr/lib/frr/bgpd -A 127.0.0.1 -M snmp
Expand All @@ -63,25 +58,45 @@ autorestart=false
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=rsyslogd:running

[program:vtysh_b]
command=/usr/bin/vtysh -b
[program:fpmsyncd]
command=fpmsyncd
priority=6
autostart=false
autorestart=false
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=bgpd:running

[program:fpmsyncd]
command=fpmsyncd
[program:bgpcfgd]
command=/usr/bin/bgpcfgd
priority=6
autostart=false
autorestart=false
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=bgpd:running

{% if DEVICE_METADATA.localhost.docker_routing_config_mode is defined and DEVICE_METADATA.localhost.docker_routing_config_mode == "unified" %}
[program:vtysh_b]
command=/usr/bin/vtysh -b
priority=6
autostart=false
autorestart=false
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=rsyslogd:running
{% endif %}

{% if WARM_RESTART is defined and WARM_RESTART.bgp is defined and WARM_RESTART.bgp.bgp_eoiu is defined and WARM_RESTART.bgp.bgp_eoiu == "true" %}
[program:bgp_eoiu_marker]
command=/usr/bin/bgp_eoiu_marker.py
priority=7
Expand All @@ -91,3 +106,6 @@ startsecs=0
startretries=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=rsyslogd:running
{% endif %}
6 changes: 0 additions & 6 deletions dockers/docker-iccpd/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,3 @@ sonic-cfggen -d -t /usr/share/sonic/templates/iccpd.j2 > $ICCPD_CONF_PATH/iccpd.

mkdir -p /var/sonic
echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status

rm -f /var/run/rsyslogd.pid

supervisorctl start rsyslogd

supervisorctl start iccpd
25 changes: 19 additions & 6 deletions dockers/docker-iccpd/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,33 @@ logfile_maxbytes=1MB
logfile_backups=2
nodaemon=true

[program:start.sh]
command=/usr/bin/start.sh
priority=1
[eventlistener:dependent-startup]
command=python -m supervisord_dependent_startup
autostart=true
autorestart=unexpected
startretries=0
exitcodes=0,3
events=PROCESS_STATE

[program:rsyslogd]
command=/usr/sbin/rsyslogd -n -iNONE
priority=1
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true

[program:rsyslogd]
command=/usr/sbin/rsyslogd -n
[program:start]
command=/usr/bin/start.sh
priority=2
autostart=false
autorestart=false
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=rsyslogd:running

[program:iccpd]
command=/usr/bin/iccpd.sh
Expand All @@ -26,4 +38,5 @@ autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

dependent_startup=true
dependent_startup_wait_for=start:exited
1 change: 1 addition & 0 deletions dockers/docker-lldp-sv2/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ RUN apt-get purge -y python-pip && \

COPY ["docker-lldp-init.sh", "/usr/bin/"]
COPY ["start.sh", "/usr/bin/"]
COPY ["waitfor_lldp_ready.sh", "/usr/bin/"]
COPY ["supervisord.conf.j2", "/usr/share/sonic/templates/"]
COPY ["lldpd.conf.j2", "/usr/share/sonic/templates/"]
COPY ["lldpd", "/etc/default/"]
Expand Down
Loading