-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add initial support for keeping track of and displaying reboot cause #1812
Conversation
files/image_config/platform/rc.local
Outdated
@@ -11,6 +11,9 @@ | |||
# | |||
# By default this script does nothing. | |||
|
|||
eval SONIC_VERSION=$(cat /etc/sonic/sonic_version.yml | grep build_version | cut -f2 -d" ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SONIC_VERSION [](start = 5, length = 13)
The cat/grep way will include quotation mark.
Try
sonic-cfggen -y /etc/sonic/sonic_version.yml -v build_version
``` #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't write this, I just moved it. The use of eval
evaluates the expression inside the quotation marks. I can change and test it, though, if you'd like.
files/image_config/platform/rc.local
Outdated
# REBOOT_CAUSE_FILE should always exist, but we add the else case | ||
# to ensure we always generate PREVIOUS_REBOOT_CAUSE_FILE here | ||
if [ -f $FIRST_BOOT_FILE ]; then | ||
echo "SONiC firmware upgrade" > $PREVIOUS_REBOOT_CAUSE_FILE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SONiC firmware upgrade [](start = 14, length = 22)
How about "First boot". "Firmware" is confusing. #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "first boot" is far more confusing to an end-user, especially if the device has been in production for a while and was recently upgraded. If you don't like "firmware," I would suggest SONiC operating system upgrade
, SONiC OS upgrade
or SONiC image upgrade
as alternatives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Then 'upgrade' is also confusing. Technically the first SONiC installation is not a upgrade.
Maybe the general "Unknown reboot cause" is good enough, since the currently implementation know nothing about first reboot and sonic upgrade.
In reply to: 197971849 [](ancestors = 197971849)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point, but I think it's more useful to know that the last time the device rebooted was due to a firmware upgrade, as opposed to stating "Unknown reboot cause". Maybe SONiC image installation
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As comments.
* d03ba4f [202012] [portstat, intfstat] added rates and utilization (sonic-net#1812) * 499ad3f [config reload] Fix config reload failure due to sonic.target job cancellation (sonic-net#1814) * 96d658c [202012][sonic installer] Add swap setup support (sonic-net#1815) * a9c6970 platform pre-check for reboot in 202012 branch (sonic-net#1788) * 0e0478b Unify the number format in the ourput of portstat and pfcstat in all cases (sonic-net#1795) * 2d1e00e [ecnconfig] Fix exception seen during display and add unit tests (sonic-net#1784) (sonic-net#1789) Signed-off-by: Volodymyr Samotiy <[email protected]>
Signed-off-by: Vivek Reddy Karri <[email protected]> d03ba4fa [202012] [portstat, intfstat] added rates and utilization (sonic-net#1812) 499ad3f4 [config reload] Fix config reload failure due to sonic.target job cancellation (sonic-net#1814) 96d658c2 [202012][sonic installer] Add swap setup support (sonic-net#1815) a9c69702 platform pre-check for reboot in 202012 branch (sonic-net#1788) 0e0478ba Unify the number format in the ourput of portstat and pfcstat in all cases (sonic-net#1795) 2d1e00ed [ecnconfig] Fix exception seen during display and add unit tests (sonic-net#1784) (sonic-net#1789)
* d03ba4f [202012] [portstat, intfstat] added rates and utilization (#1812) * 499ad3f [config reload] Fix config reload failure due to sonic.target job cancellation (#1814) * 96d658c [202012][sonic installer] Add swap setup support (#1815) * a9c6970 platform pre-check for reboot in 202012 branch (#1788) * 0e0478b Unify the number format in the ourput of portstat and pfcstat in all cases (#1795) * 2d1e00e [ecnconfig] Fix exception seen during display and add unit tests (#1784) (#1789) Signed-off-by: Volodymyr Samotiy <[email protected]>
- What I did
Add initial support for keeping track of and displaying reboot cause
- How I did it
Upon boot, rc.local determines the cause of the previous reboot and generates
/var/cache/sonic/previous-reboot-cause.txt
to contain the cause. This is determined as follows:SONiC image installation
/var/cache/sonic/reboot-cause.txt
(which should contain the cause of the previous reboot -- see below) to/var/cache/sonic/previous-reboot-cause.txt
/var/cache/sonic/reboot-cause.txt
does not exist, it writesUnknown reboot cause
rc.local then generates a new
/var/cache/sonic/reboot-cause.txt
file containing the default cause ofUnexpected reboot
. This file should be updated before going down for reboot if the cause is known. This is currently only done in the reboot wrapper script in sonic-utilities, which updates the file when a user issues thereboot
command.The new command
show reboot-cause
can be used to display the previous reboot cause. Sample output:Also reorganized rc.local such that the file contains (in order) constant declarations, function definitions, main body
Also renamed constants using all caps
- How to verify it
show reboot-cause
and confirm the output is expected.- For the future