-
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
[DELLEMC][S6000] Platform 2.0 Reboot Reason and fixed issue in process-reboot-cause #3156
[DELLEMC][S6000] Platform 2.0 Reboot Reason and fixed issue in process-reboot-cause #3156
Conversation
@@ -70,7 +70,7 @@ def main(): | |||
# if there is no sonic_platform package installed, we only provide | |||
# software-related reboot causes. | |||
try: | |||
import sonic_platform | |||
import sonic_platform.platform |
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.
Why is this necessary?
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.
Hi Joe,
sonic_platform is directory. platform is the file.
When we import directory alone We get the following error.
From File :- /usr/bin/process-reboot-cause
import sonic_platform
# Check if the previous reboot was caused by hardware
platform = sonic_platform.platform.Platform()
chassis = platform.get_chassis()
hardware_reboot_cause, optional_details = chassis.get_reboot_cause()
root@sonic:/home/admin# /usr/bin/process-reboot-cause
Traceback (most recent call last):
File "/usr/bin/process-reboot-cause", line 121, in
main()
File "/usr/bin/process-reboot-cause", line 76, in main
platform = sonic_platform.platform.Platform()
AttributeError: 'module' object has no attribute 'platform'
When we import the file "platform" the script is working
import sonic_platform.platform
# Check if the previous reboot was caused by hardware
platform = sonic_platform.platform.Platform()
chassis = platform.get_chassis()
hardware_reboot_cause, optional_details = chassis.get_reboot_cause()
root@sonic:/home/admin# /usr/bin/process-reboot-cause
root@sonic:/home/admin# <<<<<<<<<<<<< No Error
Please let me know if my understanding is fine.
Thanks
Sridhar.R
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.
Hmmm. I don't believe this should be necessary. You should be able to import the entire package by specifying the package (directory) name. Let me look into this further.
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.
It appears for this to work, you need to modify the init.py file of your sonic_platform package to either import the files and/or list the module names in __all__
. See: https://docs.python.org/3/tutorial/modules.html#importing-from-a-package
I should probably also do this for sonic_platform_base, as well.
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.
Hi Joe,
After some literature study, i was able to successfully make it work. Updated init.py with
all = ["platform", "chassis"]
from sonic_platform import *
On adding these 2 lines, "import sonic_platform" works fine.
On adding new files like sfp.py , psu.py, device,py, we have to update the init.py file as well.
Thanks for your help and support Joe.
Thanks
Sridhar.R
@@ -1,6 +1,6 @@ | |||
[Unit] | |||
Description=Reboot cause determination service | |||
After=rc-local.service | |||
After=pmon.service |
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.
Why change this?
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.
Hi Joe,
The hardware drivers required to provide reboot reason are installed only inside platform-modules-XXXX service.
When process-reboot-cause service starts before the pmon service, loading of drivers are not complete and it leads to race condition where the show reboot-cause CLI return incorrect answers.
If process-reboot-cause loads after pmon.service, the platform drivers would have successfully loaded by then and show reboot-cause cli will return correct value
Thanks
Sridhar.R
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.
Hi Sridhar,
SONiC requires that hardware reboot reason and watchdog functionality need to be available in the host OS. The sonic_platform package should be installed in both the host OS and PMon container. Host OS services should not have any dependencies on the containers. We want reboot cause and watchdog to be as reliable as possible. Thanks.
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.
Hi Joe,
Thanks for the input. I have removed the pmon dependency from process-restart-cause service.
Thanks
Sridhar.R
Retest vs please |
Hi, Could you please port this changes to november branch and 201904 branch |
@sridhar-ravindran: will this PR cherry-pick cleanly into those branches? |
Hi @jleveque |
This PR cannot be cherry-picked into 201811 branch directly. Can you make an PR 201811? |
…net#3156) Added Reboot Reason for S6000 in platform 2.0 Fixed issue in process-reboot-cause Added package uninstall code in platform de-init code for z9100, s6100 - How I did it -> Added support for S6000 Reboot Reason -> Added platform.py for all platforms -> Verified show reboot-cause command with the code changes. Added UT logs with show reboot-cause -> Modified process-reboot-cause service to start after pmon.service. In S6000, we have to wait for nvram to be loaded. -> If reboot-cause service starts before pmon.service, show reboot-cause is showing incorrect reason. -> Bug fix in process-reboot-cause file - import sonic_platform + import sonic_platform.platform
- What I did
- How I did it
-> Added support for S6000 Reboot Reason
-> Added platform.py for all platforms
-> Verified show reboot-cause command with the code changes. Added UT logs with show reboot-cause
-> Modified process-reboot-cause service to start after pmon.service. In S6000, we have to wait for nvram to be loaded.
-> If reboot-cause service starts before pmon.service, show reboot-cause is showing incorrect reason.
-> Bug fix in process-reboot-cause file
- import sonic_platform
+ import sonic_platform.platform
Changes to be committed:
(use "git reset HEAD ..." to unstage)
- How to verify it
Verified show reboot-cause command with the code changes. Added UT logs with show reboot-cause
- Description for the changelog
Added Reboot reason for S6000 and fix issue in process-reboot-cause
- A picture of a cute animal (not mandatory but encouraged)