Skip to content

Commit

Permalink
[cisco|express-boot]: Add support for cisco express boot in sonic-uti…
Browse files Browse the repository at this point in the history
…lities (sonic-net#3056)

[cisco|express-boot]: Add support for cisco express boot in sonic-utilities
  • Loading branch information
jhli-cisco authored Dec 3, 2024
1 parent f6b9912 commit b767cb8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
1 change: 1 addition & 0 deletions scripts/express-reboot
46 changes: 33 additions & 13 deletions scripts/fast-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function init_warm_reboot_states()
# If the current running instance was booted up with warm reboot. Then
# the current DB contents will likely mark warm reboot is done.
# Clear these states so that the next boot up image won't get confused.
if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" || "$REBOOT_TYPE" = "fast-reboot" ]]; then
if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" || "$REBOOT_TYPE" = "express-reboot" || "$REBOOT_TYPE" = "fast-reboot" ]]; then
sonic-db-cli STATE_DB eval "
for _, key in ipairs(redis.call('keys', 'WARM_RESTART_TABLE|*')) do
redis.call('hdel', key, 'state')
Expand All @@ -197,8 +197,13 @@ function request_pre_shutdown()
debug "Requesting platform reboot pre-check ..."
${DEVPATH}/${PLATFORM}/${PLATFORM_REBOOT_PRE_CHECK} ${REBOOT_TYPE}
fi
debug "Requesting pre-shutdown ..."
STATE=$(timeout 5s docker exec syncd /usr/bin/syncd_request_shutdown --pre &> /dev/null; if [[ $? == 124 ]]; then echo "timed out"; fi)
if [[ "$REBOOT_TYPE" = "express-reboot" ]]; then
debug "Requesting express boot pre-shutdown ..."
STATE=$(timeout 5s docker exec syncd /usr/bin/syncd_request_shutdown --pxe &> /dev/null; if [[ $? == 124 ]]; then echo "timed out"; fi)
else
debug "Requesting pre-shutdown ..."
STATE=$(timeout 5s docker exec syncd /usr/bin/syncd_request_shutdown --pre &> /dev/null; if [[ $? == 124 ]]; then echo "timed out"; fi)
fi
if [[ x"${STATE}" == x"timed out" ]]; then
error "Failed to request pre-shutdown"
fi
Expand Down Expand Up @@ -245,7 +250,7 @@ function backup_database()
{
debug "Backing up database ..."
if [[ "$REBOOT_TYPE" = "fastfast-reboot" || "$REBOOT_TYPE" = "fast-reboot" ]]; then
if [[ "$REBOOT_TYPE" = "fastfast-reboot" || "$REBOOT_TYPE" = "express-reboot" || "$REBOOT_TYPE" = "fast-reboot" ]]; then
# Advanced reboot: dump state to host disk
sonic-db-cli ASIC_DB FLUSHDB > /dev/null
sonic-db-cli COUNTERS_DB FLUSHDB > /dev/null
Expand Down Expand Up @@ -475,7 +480,7 @@ function check_docker_exec()
function check_db_integrity()
{
if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" || "$REBOOT_TYPE" = "fast-reboot" ]]; then
if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" || "$REBOOT_TYPE" = "express-reboot" || "$REBOOT_TYPE" = "fast-reboot" ]]; then
CHECK_DB_INTEGRITY=0
/usr/local/bin/check_db_integrity.py || CHECK_DB_INTEGRITY=$?
if [[ CHECK_DB_INTEGRITY -ne 0 ]]; then
Expand Down Expand Up @@ -520,7 +525,7 @@ function reboot_pre_check()
# Make sure ASIC configuration has not changed between images
ASIC_CONFIG_CHECK_SCRIPT="/usr/local/bin/asic_config_check"
ASIC_CONFIG_CHECK_SUCCESS=0
if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" ]]; then
if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" || "$REBOOT_TYPE" = "express-reboot" ]]; then
ASIC_CONFIG_CHECK_EXIT_CODE=0
${ASIC_CONFIG_CHECK_SCRIPT} || ASIC_CONFIG_CHECK_EXIT_CODE=$?
Expand Down Expand Up @@ -604,6 +609,9 @@ function check_conflict_boot_in_fw_update() {
"warm-reboot")
FW_AU_TASK_FILE_EXP="${FIRMWARE_AU_STATUS_DIR}/warm_fw_au_task"
;;
"express-reboot")
FW_AU_TASK_FILE_EXP="${FIRMWARE_AU_STATUS_DIR}/express_fw_au_task"
;;
esac
FW_AU_TASK_FILE=$(compgen -G ${FW_AU_TASK_FILE_REGEX}) || true
if [[ -n "${FW_AU_TASK_FILE}" ]] && [[ ! -f "${FW_AU_TASK_FILE_EXP}" ]]; then
Expand Down Expand Up @@ -631,12 +639,15 @@ if [[ x"${DETACH}" == x"yes" && x"${ALREADY_DETACHED}" == x"" ]]; then
exit $?
fi
sonic_asic_type=$(sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type)
if [[ "$REBOOT_TYPE" = "express-reboot" ]] && [[ "$sonic_asic_type" != "cisco-8000" ]]; then
echo "eXpress Boot is not supported"
exit "${EXIT_FAILURE}"
fi
check_conflict_boot_in_fw_update
sonic_asic_type=$(sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type)
# Check reboot type supported
BOOT_TYPE_ARG="cold"
case "$REBOOT_TYPE" in
Expand All @@ -662,6 +673,12 @@ case "$REBOOT_TYPE" in
trap clear_boot EXIT HUP INT QUIT TERM KILL ABRT ALRM
config warm_restart enable system
;;
"express-reboot")
check_warm_restart_in_progress
BOOT_TYPE_ARG="express"
trap clear_boot EXIT HUP INT QUIT TERM KILL ABRT ALRM
config warm_restart enable system
;;
*)
error "Not supported reboot type: $REBOOT_TYPE"
exit "${EXIT_NOT_SUPPORTED}"
Expand Down Expand Up @@ -710,7 +727,6 @@ if [[ "$sonic_asic_type" == "mellanox" ]]; then
fi
fi
if is_secureboot && grep -q aboot_machine= /host/machine.conf; then
load_aboot_secureboot_kernel
else
Expand All @@ -731,7 +747,7 @@ init_warm_reboot_states
setup_control_plane_assistant
TEAMD_INCREASE_RETRY_COUNT=0
if [[ "${REBOOT_TYPE}" = "warm-reboot" || "${REBOOT_TYPE}" = "fastfast-reboot" ]]; then
if [[ "${REBOOT_TYPE}" = "warm-reboot" || "${REBOOT_TYPE}" = "fastfast-reboot" || "$REBOOT_TYPE" = "express-reboot" ]]; then
TEAMD_RETRY_COUNT_PROBE_RC=0
/usr/local/bin/teamd_increase_retry_count.py --probe-only || TEAMD_RETRY_COUNT_PROBE_RC=$?
if [[ ${TEAMD_RETRY_COUNT_PROBE_RC} -ne 0 ]]; then
Expand All @@ -746,7 +762,7 @@ if [[ "${REBOOT_TYPE}" = "warm-reboot" || "${REBOOT_TYPE}" = "fastfast-reboot" ]
fi
fi
if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" || "$REBOOT_TYPE" = "fast-reboot" ]]; then
if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" || "$REBOOT_TYPE" = "express-reboot" || "$REBOOT_TYPE" = "fast-reboot" ]]; then
# Freeze orchagent for warm restart
# Ask orchagent_restart_check to try freeze 5 times with interval of 2 seconds,
# it is possible that the orchagent is in transient state and no opportunity to freeze
Expand Down Expand Up @@ -774,7 +790,7 @@ if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then
fi
fi
if [[ ( "${REBOOT_TYPE}" = "warm-reboot" || "${REBOOT_TYPE}" = "fastfast-reboot" ) && "${TEAMD_INCREASE_RETRY_COUNT}" -eq 1 ]]; then
if [[ ( "${REBOOT_TYPE}" = "warm-reboot" || "${REBOOT_TYPE}" = "fastfast-reboot" || "${REBOOT_TYPE}" = "express-reboot" ) && "${TEAMD_INCREASE_RETRY_COUNT}" -eq 1 ]]; then
/usr/local/bin/teamd_increase_retry_count.py
fi
Expand Down Expand Up @@ -817,6 +833,10 @@ for timer in ${TIMERS}; do
debug "Stopped ${timer} ..."
done
if [[ "${REBOOT_TYPE}" == "express-reboot" ]]; then
SHUTDOWN_ORDER_FILE="/etc/sonic/warm-reboot_order"
fi
if [[ -f ${SHUTDOWN_ORDER_FILE} ]]; then
SERVICES_TO_STOP="$(cat ${SHUTDOWN_ORDER_FILE})"
else
Expand Down Expand Up @@ -853,7 +873,7 @@ for service in ${SERVICES_TO_STOP}; do
debug "Stopped ${service}"
if [[ "${service}" = "swss" ]]; then
if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" ]]; then
if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" || "$REBOOT_TYPE" = "express-reboot" ]]; then
# Pre-shutdown syncd
initialize_pre_shutdown
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
'scripts/dump_nat_entries.py',
'scripts/debug_voq_chassis_packet_drops.sh',
'scripts/ecnconfig',
'scripts/express-reboot',
'scripts/fabricstat',
'scripts/fanshow',
'scripts/fast-reboot',
Expand Down

0 comments on commit b767cb8

Please sign in to comment.