[FRR] Create a separate script to wait zebra to be ready to receive connections (#6519)
The requirement for zebra to be ready to accept connections is a generic problem that is not specific to bgpd. Making the script to wait for zebra socket a separate script and let bgpd and staticd to wait for zebra socket.
This commit is contained in:
parent
7fc8caa36b
commit
fc825f9a58
@ -54,9 +54,10 @@ COPY ["TSA", "/usr/bin/TSA"]
|
|||||||
COPY ["TSB", "/usr/bin/TSB"]
|
COPY ["TSB", "/usr/bin/TSB"]
|
||||||
COPY ["TSC", "/usr/bin/TSC"]
|
COPY ["TSC", "/usr/bin/TSC"]
|
||||||
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
|
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 && \
|
RUN chmod a+x /usr/bin/TSA && \
|
||||||
chmod a+x /usr/bin/TSB && \
|
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"]
|
ENTRYPOINT ["/usr/bin/docker_init.sh"]
|
||||||
|
@ -39,6 +39,17 @@ stderr_logfile=syslog
|
|||||||
dependent_startup=true
|
dependent_startup=true
|
||||||
dependent_startup_wait_for=rsyslogd:running
|
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]
|
[program:staticd]
|
||||||
command=/usr/lib/frr/staticd -A 127.0.0.1
|
command=/usr/lib/frr/staticd -A 127.0.0.1
|
||||||
priority=4
|
priority=4
|
||||||
@ -48,7 +59,7 @@ startsecs=0
|
|||||||
stdout_logfile=syslog
|
stdout_logfile=syslog
|
||||||
stderr_logfile=syslog
|
stderr_logfile=syslog
|
||||||
dependent_startup=true
|
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" %}
|
{% if DEVICE_METADATA.localhost.frr_mgmt_framework_config is defined and DEVICE_METADATA.localhost.frr_mgmt_framework_config == "true" %}
|
||||||
[program:bfdd]
|
[program:bfdd]
|
||||||
@ -65,7 +76,7 @@ dependent_startup_wait_for=zebra:running
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
[program:bgpd]
|
[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
|
priority=5
|
||||||
stopsignal=KILL
|
stopsignal=KILL
|
||||||
autostart=false
|
autostart=false
|
||||||
@ -74,7 +85,7 @@ startsecs=0
|
|||||||
stdout_logfile=syslog
|
stdout_logfile=syslog
|
||||||
stderr_logfile=syslog
|
stderr_logfile=syslog
|
||||||
dependent_startup=true
|
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" %}
|
{% if DEVICE_METADATA.localhost.frr_mgmt_framework_config is defined and DEVICE_METADATA.localhost.frr_mgmt_framework_config == "true" %}
|
||||||
[program:ospfd]
|
[program:ospfd]
|
||||||
|
@ -5,8 +5,8 @@ port=2601
|
|||||||
|
|
||||||
function help()
|
function help()
|
||||||
{
|
{
|
||||||
echo "This script aims to ensure zebra is ready to accept connections before starting bgpd"
|
echo "This script aims to ensure zebra is ready to accept connections"
|
||||||
echo "Usage: $0 [options] [bgpd options]"
|
echo "Usage: $0 [options]"
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " -a Zebra address"
|
echo " -a Zebra address"
|
||||||
echo " -o Zebra port"
|
echo " -o Zebra port"
|
||||||
@ -23,11 +23,14 @@ while getopts ":a:o:h" opt; do
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $((OPTIND-1))
|
|
||||||
|
|
||||||
|
start=$(date +%s.%N)
|
||||||
timeout 5s bash -c -- "until </dev/tcp/${addr}/${port}; do sleep 0.1;done"
|
timeout 5s bash -c -- "until </dev/tcp/${addr}/${port}; do sleep 0.1;done"
|
||||||
if [ "$?" != "0" ]; then
|
if [ "$?" != "0" ]; then
|
||||||
logger -p error "Error: zebra is not ready to accept connections"
|
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
|
fi
|
||||||
|
|
||||||
exec /usr/lib/frr/bgpd "$@"
|
exit 0
|
Loading…
Reference in New Issue
Block a user