Skip to content

Commit a363c7f

Browse files
vvolamgpunathilell
andauthored
[SmartSwitch] Extend reboot script for rebooting SmartSwitch (sonic-net#3566)
What I did Extended reboot script for SmartSwitch cases to reboot entire SmartSwitch or a specific DPU How I did it Implemented changes according to SmartSwitch Reboot flow HLD How to verify it Verified the script on non-smart switch and didn't find any regressions. Also, script throws errors if any new smart switch related parameters are given by user. Verified on NVIDIA smart switch. --------- Co-authored-by: Gagan Punathil Ellath <[email protected]>
1 parent 5e3b132 commit a363c7f

File tree

7 files changed

+632
-2
lines changed

7 files changed

+632
-2
lines changed

scripts/reboot

+39-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ declare -r EXIT_ERROR=1
55
declare -r WATCHDOG_UTIL="/usr/local/bin/watchdogutil"
66
declare -r PRE_REBOOT_HOOK="pre_reboot_hook"
77

8+
source reboot_smartswitch_helper
9+
810
DEVPATH="/usr/share/sonic/device"
911
PLAT_REBOOT="platform_reboot"
1012
PLATFORM_UPDATE_REBOOT_CAUSE="platform_update_reboot_cause"
@@ -37,10 +39,16 @@ EXIT_NEXT_IMAGE_NOT_EXISTS=4
3739
EXIT_SONIC_INSTALLER_VERIFY_REBOOT=21
3840
EXIT_PLATFORM_FW_AU_FAILURE=22
3941
PLATFORM_FWUTIL_AU_REBOOT_HANDLE="platform_fw_au_reboot_handle"
42+
PLATFORM_JSON_FILE="platform.json"
43+
PLATFORM_JSON_PATH="${DEVPATH}/${PLATFORM}/${PLATFORM_JSON_FILE}"
4044
REBOOT_SCRIPT_NAME=$(basename $0)
4145
REBOOT_TYPE="${REBOOT_SCRIPT_NAME}"
4246
TAG_LATEST=no
4347
REBOOT_FLAGS=""
48+
SMART_SWITCH="no"
49+
DPU_MODULE_NAME=""
50+
REBOOT_DPU="no"
51+
PRE_SHUTDOWN="no"
4452

4553
function debug()
4654
{
@@ -64,6 +72,9 @@ function stop_pmon_service()
6472
{
6573
CONTAINER_STOP_RC=0
6674
debug "Stopping pmon docker"
75+
if [[ "${PRE_SHUTDOWN}" == "yes" ]]; then
76+
systemctl disable pmon
77+
fi
6778
systemctl stop pmon || debug "Ignore stopping pmon error $?"
6879
docker kill pmon &> /dev/null || CONTAINER_STOP_RC=$?
6980
if [[ CONTAINER_STOP_RC -ne 0 ]]; then
@@ -128,6 +139,8 @@ function show_help_and_exit()
128139
echo " "
129140
echo " Available options:"
130141
echo " -h, -? : getting this help"
142+
echo " -d : DPU module name on a smart switch, option is invalid when on DPU"
143+
echo " -p : Pre-shutdown steps on DPU, invalid on NPU"
131144

132145
exit ${EXIT_SUCCESS}
133146
}
@@ -154,7 +167,7 @@ function reboot_pre_check()
154167
${DEVPATH}/${PLATFORM}/${PLATFORM_REBOOT_PRE_CHECK}
155168
[[ $? -ne 0 ]] && exit $?
156169
fi
157-
170+
158171
# Verify the next image by sonic-installer
159172
local message=$(sonic-installer verify-next-image 2>&1)
160173
if [ $? -ne 0 ]; then
@@ -178,7 +191,7 @@ function check_conflict_boot_in_fw_update()
178191

179192
function parse_options()
180193
{
181-
while getopts "h?vf" opt; do
194+
while getopts "h?vfpd:" opt; do
182195
case ${opt} in
183196
h|\? )
184197
show_help_and_exit
@@ -192,6 +205,13 @@ function parse_options()
192205
f )
193206
REBOOT_FLAGS+=" -f"
194207
;;
208+
d )
209+
REBOOT_DPU="yes"
210+
DPU_MODULE_NAME="$OPTARG"
211+
;;
212+
p )
213+
PRE_SHUTDOWN="yes"
214+
;;
195215
esac
196216
done
197217
}
@@ -225,6 +245,18 @@ fi
225245

226246
debug "User requested rebooting device ..."
227247

248+
handle_smart_switch "$REBOOT_DPU" "$PRE_SHUTDOWN" "$DPU_MODULE_NAME"
249+
smart_switch_result=$?
250+
if [[ $smart_switch_result -ne 0 ]]; then
251+
exit $smart_switch_result
252+
fi
253+
254+
# On a smartswitch, complete the DPU reboot and exit
255+
smartswitch=$(is_smartswitch)
256+
if [ "$smartswitch" == "True" ] && [ "$REBOOT_DPU" == "yes" ]; then
257+
exit $smart_switch_result
258+
fi
259+
228260
check_conflict_boot_in_fw_update
229261

230262
setup_reboot_variables
@@ -287,6 +319,11 @@ if [ -x ${WATCHDOG_UTIL} ]; then
287319
${WATCHDOG_UTIL} arm
288320
fi
289321

322+
if [[ "${PRE_SHUTDOWN}" == "yes" ]]; then
323+
echo "${DPU_MODULE_NAME} pre-shutdown steps are completed"
324+
exit ${EXIT_SUCCESS}
325+
fi
326+
290327
if [ -x ${DEVPATH}/${PLATFORM}/${PLAT_REBOOT} ]; then
291328
VERBOSE=yes debug "Rebooting with platform ${PLATFORM} specific tool ..."
292329
${DEVPATH}/${PLATFORM}/${PLAT_REBOOT} $@

0 commit comments

Comments
 (0)