sonic-utilities
sonic-utilities copied to clipboard
reboot mechanism enhanced with reboot cause
What I did
- Prior to this change, reboot script is only externally trigged where reboot cause is always fixed i.e. (default's to 'user issued reboot command')
- In this PR (changeset), SONiC reboot is enhanced to accept reboot cause (reason) as an optional argument
- This enhancement enables system applications' (e.g. Fault detector/producer, Fault Manager/Handler) to pass reboot cause as an argument while initiating (system level) reboot
- This reboot cause in turn is saved to REBOOT_CAUSE_FILE for tracking and debugging purposes
How I did it
- Facilitated passing of a new optional argument (-r) to reboot command and handled it in reboot script
- For further details, refer to the 'Files changed' tab
How to verify it
Refer to UT scenarios and logs: UT-reboot.txt
root@sonic:/home/cisco# reboot -h Usage /usr/local/bin/reboot [options] Request rebooting the device. Invoke platform-specific tool when available. This script will shutdown syncd before rebooting.
Available options:
-h, -? : getting this help
-f : execute reboot force
-r : specify reboot cause (reason) string in quotes
root@sonic:/home/cisco#
root@sonic:/home/cisco# reboot -r "rebooting due to xyz reason" reboot_cause: rebooting due to xyz reason requested COLD shutdown /var/log: 0 B (0 bytes) trimmed on /dev/loop1 /host: 204.6 MiB (214548480 bytes) trimmed on /dev/sda3 Tue 06 Feb 2024 06:20:22 AM UTC Issuing OS-level reboot ... Going to issue reboot command... reboot cause specified root@sonic:/home/cisco#
root@sonic:/home/cisco# show reboot-cause history Name Cause
2024_02_06_06_23_30 System triggered reboot. reason: 'rebooting due to xyz reason' [User: system, Time: Tue 06 Feb 2024 06:20:13 AM UTC]
2024_02_06_01_07_29 reboot Tue 06 Feb 2024 01:04:43 AM UTC
Previous command output (if the output of a command-line utility has changed)
root@sonic:/home/cisco# reboot requested COLD shutdown /var/log: 0 B (0 bytes) trimmed on /dev/loop1 /host: 204.6 MiB (214548480 bytes) trimmed on /dev/sda3 Tue 06 Feb 2024 06:20:22 AM UTC Issuing OS-level reboot ... root@sonic:/home/cisco#
New command output (if the output of a command-line utility has changed)
Note: Above-mentioned default 'reboot' command is kept intact.
Additional (optional) argument -r, if passed to the reboot, would have following outcome: root@sonic:/home/cisco# reboot -r "rebooting due to xyz reason" reboot_cause: rebooting due to xyz reason requested COLD shutdown /var/log: 0 B (0 bytes) trimmed on /dev/loop1 /host: 204.6 MiB (214548480 bytes) trimmed on /dev/sda3 Tue 06 Feb 2024 06:20:22 AM UTC Issuing OS-level reboot ... Going to issue reboot command... reboot cause specified root@sonic:/home/cisco#
UT test scenario and logs: UT-reboot.txt
LGTM