[reboot-cause] Porting PR to fix a broken symlink of previous-reboot-cause file removal issue (sonic-host-services #46)#14106
Merged
yxieca merged 1 commit intosonic-net:202205from Mar 8, 2023
Conversation
…cause file removal issue (sonic-host-services sonic-net#46) Signed-off-by: mlok <marty.lok@nokia.com>
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. |
8 tasks
abdosi
approved these changes
Mar 6, 2023
gechiang
approved these changes
Mar 6, 2023
Contributor
|
@mlok-nokia when the issue is hit, there are no reboot-cause json files in |
Contributor
Author
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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
Which release branch to backport (provide reason below if selected)
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)