-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "[201803] [services] Restart SwSS service upon unexpected crit…
- Loading branch information
Showing
19 changed files
with
60 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,42 @@ | ||
#!/usr/bin/env bash | ||
|
||
STATE_DB_IDX="6" | ||
|
||
PORT_TABLE_PREFIX="PORT_TABLE" | ||
VLAN_TABLE_PREFIX="VLAN_TABLE" | ||
LAG_TABLE_PREFIX="LAG_TABLE" | ||
|
||
function wait_until_iface_ready | ||
{ | ||
TABLE_PREFIX=$1 | ||
IFACE=$2 | ||
IFACE=$1 | ||
|
||
echo "Waiting until interface $IFACE is up..." | ||
|
||
# Wait for the interface to come up (i.e., 'ip link show' returns 0) | ||
until ip link show dev $IFACE up > /dev/null 2>&1; do | ||
sleep 1 | ||
done | ||
|
||
echo "Waiting until interface $IFACE is ready..." | ||
echo "Interface $IFACE is up" | ||
|
||
# Wait for the interface to come up | ||
# (i.e., interface is present in STATE_DB and state is "ok") | ||
echo "Waiting until interface $IFACE has an IPv4 address..." | ||
|
||
# Wait until the interface gets assigned an IPv4 address | ||
while true; do | ||
RESULT=$(redis-cli -n ${STATE_DB_IDX} HGET "${TABLE_PREFIX}|${IFACE}" "state" 2> /dev/null) | ||
if [ x"$RESULT" == x"ok" ]; then | ||
IP=$(ip -4 addr show dev $IFACE | grep "inet " | awk '{ print $2 }' | cut -d '/' -f1) | ||
|
||
if [ -n "$IP" ]; then | ||
break | ||
fi | ||
|
||
sleep 1 | ||
done | ||
|
||
echo "Interface ${IFACE} is ready!" | ||
echo "Interface $IFACE is configured with IP $IP" | ||
} | ||
|
||
|
||
# Wait for all interfaces to be up and ready | ||
# Wait for all interfaces to come up and have IPv4 addresses assigned | ||
{% for (name, prefix) in INTERFACE %} | ||
wait_until_iface_ready ${PORT_TABLE_PREFIX} {{ name }} | ||
wait_until_iface_ready {{ name }} | ||
{% endfor %} | ||
{% for (name, prefix) in VLAN_INTERFACE %} | ||
wait_until_iface_ready ${VLAN_TABLE_PREFIX} {{ name }} | ||
wait_until_iface_ready {{ name }} | ||
{% endfor %} | ||
{% for (name, prefix) in PORTCHANNEL_INTERFACE %} | ||
wait_until_iface_ready ${LAG_TABLE_PREFIX} {{ name }} | ||
wait_until_iface_ready {{ name }} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 26 additions & 24 deletions
50
src/sonic-config-engine/tests/sample_output/wait_for_intf.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,43 @@ | ||
#!/usr/bin/env bash | ||
|
||
STATE_DB_IDX="6" | ||
|
||
PORT_TABLE_PREFIX="PORT_TABLE" | ||
VLAN_TABLE_PREFIX="VLAN_TABLE" | ||
LAG_TABLE_PREFIX="LAG_TABLE" | ||
|
||
function wait_until_iface_ready | ||
{ | ||
TABLE_PREFIX=$1 | ||
IFACE=$2 | ||
IFACE=$1 | ||
|
||
echo "Waiting until interface $IFACE is up..." | ||
|
||
# Wait for the interface to come up (i.e., 'ip link show' returns 0) | ||
until ip link show dev $IFACE up > /dev/null 2>&1; do | ||
sleep 1 | ||
done | ||
|
||
echo "Waiting until interface $IFACE is ready..." | ||
echo "Interface $IFACE is up" | ||
|
||
# Wait for the interface to come up | ||
# (i.e., interface is present in STATE_DB and state is "ok") | ||
echo "Waiting until interface $IFACE has an IPv4 address..." | ||
|
||
# Wait until the interface gets assigned an IPv4 address | ||
while true; do | ||
RESULT=$(redis-cli -n ${STATE_DB_IDX} HGET "${TABLE_PREFIX}|${IFACE}" "state" 2> /dev/null) | ||
if [ x"$RESULT" == x"ok" ]; then | ||
IP=$(ip -4 addr show dev $IFACE | grep "inet " | awk '{ print $2 }' | cut -d '/' -f1) | ||
|
||
if [ -n "$IP" ]; then | ||
break | ||
fi | ||
|
||
sleep 1 | ||
done | ||
|
||
echo "Interface ${IFACE} is ready!" | ||
echo "Interface $IFACE is configured with IP $IP" | ||
} | ||
|
||
|
||
# Wait for all interfaces to be up and ready | ||
wait_until_iface_ready ${VLAN_TABLE_PREFIX} Vlan1000 | ||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel04 | ||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel02 | ||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel03 | ||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel03 | ||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel01 | ||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel02 | ||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel04 | ||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel01 | ||
# Wait for all interfaces to come up and have IPv4 addresses assigned | ||
wait_until_iface_ready Vlan1000 | ||
wait_until_iface_ready PortChannel04 | ||
wait_until_iface_ready PortChannel02 | ||
wait_until_iface_ready PortChannel03 | ||
wait_until_iface_ready PortChannel03 | ||
wait_until_iface_ready PortChannel01 | ||
wait_until_iface_ready PortChannel02 | ||
wait_until_iface_ready PortChannel04 | ||
wait_until_iface_ready PortChannel01 | ||
|