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-cause] Porting PR to fix a broken symlink of previous-reboot-cause file removal issue (sonic-host-services #46) #14106

Merged

Conversation

mlok-nokia
Copy link
Contributor

Why I did it

Porting/cherry-pick PR sonic-net/sonic-host-services#46
"show reboot-cause history" shows empty history. When the previous-reboot-cause has a broken symlink, And rebooting the system will not be able to generate a new symlink of the new previous-reboot-cause.

admin@sonic:~$ show reboot-cause history 
Name    Cause    Time    User    Comment
------  -------  ------  ------  ---------

How I did it

Somehow, when the symlink file /host/reboot-cause/previous-reboot-cause is broken (which its destination files doesn't exist in this case), the current condition check "if os.path,exists(PREVIOUS_REBOOT_CAUSE_FILE)" will return False in determine-reboot-cause script. Hence, the current previous-reboot-cause is not been removed and the recreation of the new previous-reboot-cause failed. In case of previous-reboot-cause is a broken synlink file, add condition os.path.islink(PREVIOUS_REBOOT_CAUSE) to check and allow the remove operation happens.

How to verify it

  1. Manually make the /host/reboot-cause/previous-reboot-cause to be a broken symlink file by removing its destination file
  2. reboot the system. "show reboot-cause history" should show the correct info
admin@ixre-egl-board25:~$ show reboot-cause history 
Name                 Cause                                    Time                             User     Comment
-------------------  ---------------------------------------  -------------------------------  -------  ----------
2023_03_01_17_41_31  reboot                                   Wed 01 Mar 2023 05:39:27 PM UTC  admin    N/A
2023_03_01_17_14_47  reboot                                   Wed 01 Mar 2023 05:12:05 PM UTC  admin    N/A
2023_03_01_17_14_18  reboot                                   Wed 01 Mar 2023 05:12:05 PM UTC  admin    N/A
2023_03_01_16_20_52  reboot                                   Wed 01 Mar 2023 04:18:22 PM UTC  admin    N/A
2023_03_01_16_20_27  reboot                                   Wed 01 Mar 2023 04:18:22 PM UTC  admin    N/A

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211

Description for the changelog

Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

…cause file removal issue (sonic-host-services sonic-net#46)

Signed-off-by: mlok <marty.lok@nokia.com>
@mlok-nokia mlok-nokia requested a review from lguohan as a code owner March 6, 2023 15:57
@mlok-nokia
Copy link
Contributor Author

@abdosi and @judyjoseph , Per request, this PR is cherry-pick/porting from the master branch sonic-net/sonic-host-services#46. Please review it.

@prgeor
Copy link
Contributor

prgeor commented Mar 7, 2023

@mlok-nokia when the issue is hit, there are no reboot-cause json files in /host/reboot-cause/history/ ?

@yxieca yxieca merged commit 37b31c5 into sonic-net:202205 Mar 8, 2023
@mlok-nokia
Copy link
Contributor Author

@mlok-nokia when the issue is hit, there are no reboot-cause json files in /host/reboot-cause/history/ ?

Correct. When the issue happens. File /host/reboot-cause/previous-reboot-cause reference to a file in /host/reboot-cause/history/ which doesn't exist. This PR is to correct the problem which already happened and allow determine-reboot-cause to run success.

@mlok-nokia mlok-nokia deleted the porting-show-reboot-casue-issue branch September 27, 2024 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants