Skip to content

Commit 2cdf0c9

Browse files
committed
Skip reboot if DPU is not operationally online
1 parent 73300df commit 2cdf0c9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

scripts/reboot_smartswitch_helper

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,21 @@ function reboot_dpu()
165165

166166
debug "User requested rebooting device ${DPU_NAME} ..."
167167

168+
# Check if the DPU operation status is online before rebooting
169+
local oper_status
170+
oper_status=$(show chassis modules status "${DPU_NAME^^}" | sed -n '/^ *DPU/ s/.*\s\+\(Online\|Offline\)\s\+.*/\1/p')
171+
if [ $? -ne 0 ]; then
172+
log_message "ERROR: Failed to retrieve DPU status."
173+
return ${EXIT_ERROR}
174+
fi
175+
176+
log_message "INFO: DPU ${DPU_NAME} is in '$oper_status' state before reboot."
177+
oper_status=$(echo "$oper_status" | tr '[:upper:]' '[:lower:]')
178+
if [ "$oper_status" != "online" ]; then
179+
log_message "INFO: ${DPU_NAME} is not online. Current status: $oper_status"
180+
return ${EXIT_ERROR}
181+
fi
182+
168183
# Send reboot command to DPU
169184
gnmi_reboot_dpu "${DPU_NAME}"
170185
if [ $? -ne 0 ]; then

0 commit comments

Comments
 (0)