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

[FRR] Create a separate script to wait zebra to be ready to receive connections #6519

Merged
merged 3 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions dockers/docker-fpm-frr/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ COPY ["TSA", "/usr/bin/TSA"]
COPY ["TSB", "/usr/bin/TSB"]
COPY ["TSC", "/usr/bin/TSC"]
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
COPY ["bgpd.sh", "/usr/bin/"]
COPY ["zsocket.sh", "/usr/bin/"]
RUN chmod a+x /usr/bin/TSA && \
chmod a+x /usr/bin/TSB && \
chmod a+x /usr/bin/TSC
chmod a+x /usr/bin/TSC && \
chmod a+x /usr/bin/zsocket.sh

ENTRYPOINT ["/usr/bin/docker_init.sh"]
17 changes: 14 additions & 3 deletions dockers/docker-fpm-frr/frr/supervisord/supervisord.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=rsyslogd:running

[program:zsocket]
command=/usr/bin/zsocket.sh
priority=4
autostart=false
autorestart=false
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=zebra:running

[program:staticd]
command=/usr/lib/frr/staticd -A 127.0.0.1
priority=4
Expand All @@ -48,7 +59,7 @@ startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=zebra:running
dependent_startup_wait_for=zsocket:exited

{% if DEVICE_METADATA.localhost.frr_mgmt_framework_config is defined and DEVICE_METADATA.localhost.frr_mgmt_framework_config == "true" %}
[program:bfdd]
Expand All @@ -65,7 +76,7 @@ dependent_startup_wait_for=zebra:running
{% endif %}

[program:bgpd]
command=/usr/bin/bgpd.sh -A 127.0.0.1 -M snmp
command=/usr/lib/frr/bgpd -A 127.0.0.1 -M snmp
priority=5
stopsignal=KILL
autostart=false
Expand All @@ -74,7 +85,7 @@ startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=zebra:running
dependent_startup_wait_for=zsocket:exited

{% if DEVICE_METADATA.localhost.frr_mgmt_framework_config is defined and DEVICE_METADATA.localhost.frr_mgmt_framework_config == "true" %}
[program:ospfd]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ port=2601

function help()
{
echo "This script aims to ensure zebra is ready to accept connections before starting bgpd"
echo "Usage: $0 [options] [bgpd options]"
echo "This script aims to ensure zebra is ready to accept connections"
echo "Usage: $0 [options]"
echo "Options:"
echo " -a Zebra address"
echo " -o Zebra port"
Expand All @@ -23,11 +23,14 @@ while getopts ":a:o:h" opt; do
;;
esac
done
shift $((OPTIND-1))

start=$(date +%s.%N)
timeout 5s bash -c -- "until </dev/tcp/${addr}/${port}; do sleep 0.1;done"
if [ "$?" != "0" ]; then
logger -p error "Error: zebra is not ready to accept connections"
else
timespan=$(awk "BEGIN {print $(date +%s.%N)-$start; exit}")
logger -p info "It took ${timespan} seconds to wait for zebra to be ready to accept connections"
fi

exec /usr/lib/frr/bgpd "$@"
exit 0