Skip to content

Commit

Permalink
[graceful reboot] Add watchdog, add execution of pre_reboot_hook, fix…
Browse files Browse the repository at this point in the history
… --force flag bug

Signed-off-by: vadymhlushko-mlnx <[email protected]>
  • Loading branch information
vadymhlushko-mlnx committed Nov 28, 2023
1 parent 2b6b658 commit fa4ec22
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions scripts/reboot
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/bash

DEVPATH="/usr/share/sonic/device"
PLAT_REBOOT="platform_reboot"
PRE_REBOOT_HOOK="pre_reboot_hook"
PLATFORM_UPDATE_REBOOT_CAUSE="platform_update_reboot_cause"
REBOOT_CAUSE_FILE="/host/reboot-cause/reboot-cause.txt"
PLATFORM_REBOOT_PRE_CHECK="platform_reboot_pre_check"
REBOOT_TIME=$(date)
WATCHDOG_UTIL="/usr/local/bin/watchdogutil"

# Reboot immediately if we run the kdump capture kernel
VMCORE_FILE=/proc/vmcore
Expand All @@ -27,6 +30,7 @@ ASIC_TYPE=$(sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type)
SUBTYPE=$(sonic-cfggen -d -v DEVICE_METADATA.localhost.subtype)
ASAN=$(sonic-cfggen -y /etc/sonic/sonic_version.yml -v asan)
VERBOSE=no
REBOOT_FLAGS=""
EXIT_NEXT_IMAGE_NOT_EXISTS=4
EXIT_SONIC_INSTALLER_VERIFY_REBOOT=21
EXIT_PLATFORM_FW_AU_FAILURE=22
Expand Down Expand Up @@ -183,6 +187,9 @@ function parse_options()
t )
TAG_LATEST=no
;;
f )
REBOOT_FLAGS+=" -f"
;;
esac
done
}
Expand Down Expand Up @@ -242,9 +249,19 @@ if [ -x ${DEVPATH}/${PLATFORM}/${PLATFORM_UPDATE_REBOOT_CAUSE} ]; then
${DEVPATH}/${PLATFORM}/${PLATFORM_UPDATE_REBOOT_CAUSE}
fi

if [ -x ${DEVPATH}/${PLATFORM}/${PRE_REBOOT_HOOK} ]; then
debug "Executing the pre-reboot script"
${DEVPATH}/${PLATFORM}/${PRE_REBOOT_HOOK}
fi

if [ -x ${WATCHDOG_UTIL} ]; then
debug "Enabling the Watchdog before reboot"
${WATCHDOG_UTIL} arm
fi

if [ -x ${DEVPATH}/${PLATFORM}/${PLAT_REBOOT} ]; then
VERBOSE=yes debug "Rebooting with platform ${PLATFORM} specific tool ..."
${DEVPATH}/${PLATFORM}/${PLAT_REBOOT} $@
${DEVPATH}/${PLATFORM}/${PLAT_REBOOT} ${REBOOT_FLAGS}

# There are a couple reasons execution reaches here:
#
Expand All @@ -260,4 +277,4 @@ if [ -x ${DEVPATH}/${PLATFORM}/${PLAT_REBOOT} ]; then
fi

VERBOSE=yes debug "Issuing OS-level reboot ..." >&2
exec /sbin/reboot $@
exec /sbin/reboot ${REBOOT_FLAGS}

0 comments on commit fa4ec22

Please sign in to comment.