add check connetction between zebra and bgp (#16675)

Why I did it
Back port #6478 and #6519 to 201911 branch.

Work item tracking
Microsoft ADO (number only):
24978836
How I did it
Add checking the connection between zebra and bgp during bgpd start.

How to verify it
Modify start.h, add debug log and check the syslog

  _Sep 22 02:41:29.716356 str-a7060cx-acs-10 INFO bgp#root: ####: start zebra
  Sep 22 02:41:30.815341 str-a7060cx-acs-10 INFO bgp#root: ####: start check connection
  Sep 22 02:41:30.868784 str-a7060cx-acs-10 INFO bgp#root: ####: It took 0.029979 seconds to wait for zebra to be ready to accept connections
  Sep 22 02:41:30.873685 str-a7060cx-acs-10 INFO bgp#root: ####: start bgpd
  Sep 22 02:41:35.270569 str-a7060cx-acs-10 INFO bgp#root: ####: done_

  _Sep 22 03:28:02.423438 str-a7060cx-acs-10 INFO bgp#root: ####: start zebra
  Sep 22 03:28:03.731320 str-a7060cx-acs-10 INFO bgp#root: ####: start check connection
  Sep 22 03:28:33.749152 str-a7060cx-acs-10 INFO bgp#root: ####: Error: zebra is not ready to accept connections
  Sep 22 03:28:33.752490 str-a7060cx-acs-10 INFO bgp#root: ####: start bgpd
  Sep 22 03:28:34.259735 str-a7060cx-acs-10 INFO bgp#root: ####: start bgpd done
  Sep 22 03:28:34.755538 str-a7060cx-acs-10 INFO bgp#root: ####: start bgpcfgd
  Sep 22 03:28:35.800906 str-a7060cx-acs-10 INFO bgp#root: ####: done_
This commit is contained in:
Liping Xu 2023-09-25 23:29:40 +08:00 committed by GitHub
parent 42597806a9
commit 36e65035ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -82,6 +82,18 @@ fi
# Start Quagga processes
supervisorctl start zebra
supervisorctl start staticd
addr="127.0.0.1"
port=2601
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
supervisorctl start bgpd
if [ "$CONFIG_TYPE" == "unified" ]; then