Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reboot mechanism enhanced with reboot cause #3154

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shyam77git
Copy link

@shyam77git shyam77git commented Feb 6, 2024

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#

     - 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 option (argument)
     - This would enable system applications'
       (e.g. Fault Manager) 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

Signed-off-by: Shyam Kumar <shyakuma@cisco.com>
scripts/reboot Outdated Show resolved Hide resolved
scripts/reboot Outdated Show resolved Hide resolved
    - Addressed PR review comments

Signed-off-by: Shyam Kumar <shyakuma@cisco.com>
@shyam77git
Copy link
Author

UT test scenario and logs:
UT-reboot.txt

@amulyan7
Copy link
Contributor

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants