Skip to content

Commit a30d1a8

Browse files
authored
[warm/fast reboot] setup control plane assistant when available (#487)
Signed-off-by: Ying Xie <[email protected]>
1 parent 8182dfa commit a30d1a8

File tree

1 file changed

+39
-8
lines changed

1 file changed

+39
-8
lines changed

scripts/fast-reboot

+39-8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ REBOOT_TYPE="${REBOOT_SCRIPT_NAME}"
1010
VERBOSE=no
1111
FORCE=no
1212
REBOOT_METHOD="/sbin/kexec -e"
13+
ASSISTANT_IP_LIST=""
14+
ASSISTANT_SCRIPT="/usr/bin/neighbor_advertiser"
1315

1416
EXIT_SUCCESS=0
1517
EXIT_FAILURE=1
@@ -40,24 +42,22 @@ function debug()
4042
function showHelpAndExit()
4143
{
4244
echo "Usage: ${REBOOT_SCRIPT_NAME} [options]"
43-
echo " -h -? : get this help"
45+
echo " -h,-? : get this help"
4446
echo " -v : turn on verbose"
4547
echo " -f : force execution"
4648
echo " -r : reboot with /sbin/reboot"
4749
echo " -k : reboot with /sbin/kexec -e [default]"
4850
echo " -x : execute script with -x flag"
51+
echo " -c : specify control plane assistant IP list"
4952

5053
exit "${EXIT_SUCCESS}"
5154
}
5255

5356
function parseOptions()
5457
{
55-
while getopts "vfh?rkx" opt; do
58+
while getopts "vfh?rkxc:" opt; do
5659
case ${opt} in
57-
h )
58-
showHelpAndExit
59-
;;
60-
\? )
60+
h|\? )
6161
showHelpAndExit
6262
;;
6363
v )
@@ -75,18 +75,30 @@ function parseOptions()
7575
x )
7676
set -x
7777
;;
78+
c )
79+
ASSISTANT_IP_LIST=${OPTARG}
80+
;;
7881
esac
7982
done
8083
}
8184

8285
sonic_asic_type=$(sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type)
8386

87+
function clear_fast_boot()
88+
{
89+
debug "${REBOOT_TYPE} failure ($?) cleanup ..."
90+
91+
/sbin/kexec -u || /bin/true
92+
93+
teardown_control_plane_assistant
94+
}
95+
8496
function clear_warm_boot()
8597
{
86-
debug "Failure ($?) cleanup ..."
98+
clear_fast_boot
99+
87100
result=`timeout 10s config warm_restart disable; if [[ $? == 124 ]]; then echo timeout; else echo "code ($?)"; fi` || /bin/true
88101
debug "Cancel warm-reboot: ${result}"
89-
/sbin/kexec -u || /bin/true
90102
91103
TIMESTAMP=`date +%Y%m%d-%H%M%S`
92104
if [[ -f ${WARM_DIR}/${REDIS_FILE} ]]; then
@@ -170,13 +182,30 @@ function backup_database()
170182
docker exec -i database rm /var/lib/redis/$REDIS_FILE
171183
}
172184
185+
function setup_control_plane_assistant()
186+
{
187+
if [[ -n "${ASSISTANT_IP_LIST}" && -x ${ASSISTANT_SCRIPT} ]]; then
188+
debug "Setting up control plane assistant: ${ASSISTANT_IP_LIST} ..."
189+
${ASSISTANT_SCRIPT} -s ${ASSISTANT_IP_LIST} -m set
190+
fi
191+
}
192+
193+
function teardown_control_plane_assistant()
194+
{
195+
if [[ -n "${ASSISTANT_IP_LIST}" && -x ${ASSISTANT_SCRIPT} ]]; then
196+
debug "Tearing down control plane assistant: ${ASSISTANT_IP_LIST} ..."
197+
${ASSISTANT_SCRIPT} -s ${ASSISTANT_IP_LIST} -m reset
198+
fi
199+
}
200+
173201
parseOptions $@
174202
175203
# Check reboot type supported
176204
BOOT_TYPE_ARG="cold"
177205
case "$REBOOT_TYPE" in
178206
"fast-reboot")
179207
BOOT_TYPE_ARG=$REBOOT_TYPE
208+
trap clear_fast_boot EXIT HUP INT QUIT TERM KILL ABRT ALRM
180209
;;
181210
"warm-reboot")
182211
if [[ "$sonic_asic_type" == "mellanox" ]]; then
@@ -256,6 +285,8 @@ if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then
256285
/usr/bin/fast-reboot-dump.py -t /host/fast-reboot
257286
fi
258287
288+
setup_control_plane_assistant
289+
259290
if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" ]]; then
260291
# Freeze orchagent for warm restart
261292
# Try freeze 5 times, it is possible that the orchagent is in transient state and no opportunity to be freezed

0 commit comments

Comments
 (0)