Skip to content

Commit 67a0c6c

Browse files
vadymhlushko-mlnxabdosi
authored andcommitted
[warm-reboot]: added pre-check for ISSU file (sonic-net#915)
* [warm-reboot]: added pre-check for ISSU file Signed-off-by: Vadym Hlushko <[email protected]> * [warm-reboot]: fixed problems according to PR review comments Signed-off-by: Vadym Hlushko <[email protected]> * [warm-reboot]: added distinguish token and error code to clarify when issu_bank.txt was corrupted Signed-off-by: Vadym Hlushko <[email protected]> * [warm-reboot]: fixed indentation problems Signed-off-by: Vadym Hlushko <[email protected]> * [warm-reboot]: removed script interrupt when issu_bank.txt is broken Signed-off-by: Vadym Hlushko <[email protected]> * [warm-reboot]: added script interrupt if issu_bank.txt is broken before call request_pre_shutdown Signed-off-by: Vadym Hlushko <[email protected]>
1 parent 4e1e61c commit 67a0c6c

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

scripts/fast-reboot

+46
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,42 @@ function request_pre_shutdown()
156156
}
157157
}
158158
159+
function recover_issu_bank_file_instruction()
160+
{
161+
debug "To recover (${ISSU_BANK_FILE}) file, do the following:"
162+
debug "$ docker exec -it syncd sx_api_dbg_generate_dump.py"
163+
debug "$ docker exec -it syncd cat /tmp/sdkdump | grep 'ISSU Bank'"
164+
debug "Command above will print the VALUE of ISSU BANK - 0 or 1, use this VALUE in the next command"
165+
debug "$ printf VALUE > /host/warmboot/issu_bank.txt"
166+
}
167+
168+
function check_issu_bank_file()
169+
{
170+
ISSU_BANK_FILE=/host/warmboot/issu_bank.txt
171+
MLNX_ISSU_BANK_BROKEN=102
172+
173+
if [[ ! -s "$ISSU_BANK_FILE" ]]; then
174+
error "(${ISSU_BANK_FILE}) does NOT exist or empty ..."
175+
recover_issu_bank_file_instruction
176+
if [[ "$1" = true ]]; then
177+
exit "${MLNX_ISSU_BANK_BROKEN}"
178+
fi
179+
return
180+
fi
181+
182+
issu_file_chars_count=`stat -c %s ${ISSU_BANK_FILE}`;
183+
issu_file_content=`awk '{print $0}' ${ISSU_BANK_FILE}`
184+
185+
if [[ $issu_file_chars_count != 1 ]] ||
186+
[[ "$issu_file_content" != "0" && "$issu_file_content" != "1" ]]; then
187+
error "(${ISSU_BANK_FILE}) is broken ..."
188+
recover_issu_bank_file_instruction
189+
if [[ "$1" = true ]]; then
190+
exit "${MLNX_ISSU_BANK_BROKEN}"
191+
fi
192+
fi
193+
}
194+
159195
function wait_for_pre_shutdown_complete_or_fail()
160196
{
161197
debug "Waiting for pre-shutdown ..."
@@ -484,10 +520,20 @@ systemctl stop swss
484520
if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" ]]; then
485521
initialize_pre_shutdown
486522
523+
BEFORE_PRE_SHUTDOWN=true
524+
525+
if [[ "x$sonic_asic_type" == x"mellanox" ]]; then
526+
check_issu_bank_file "$BEFORE_PRE_SHUTDOWN"
527+
fi
528+
487529
request_pre_shutdown
488530
489531
wait_for_pre_shutdown_complete_or_fail
490532
533+
if [[ "x$sonic_asic_type" == x"mellanox" ]]; then
534+
check_issu_bank_file
535+
fi
536+
491537
# Warm reboot: dump state to host disk
492538
if [[ "$REBOOT_TYPE" = "fastfast-reboot" ]]; then
493539
sonic-db-cli ASIC_DB FLUSHDB > /dev/null

0 commit comments

Comments
 (0)