-
Notifications
You must be signed in to change notification settings - Fork 790
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
Fix an error of checking reboot type. #14155
Fix an error of checking reboot type. #14155
Conversation
@@ -344,7 +344,9 @@ def get_reboot_cause(dut): | |||
# is such like "User issued 'xxx' command [User: admin, Time: Sun Aug 4 06:43:19 PM UTC 2024]" | |||
# So, use the above pattern to get real reboot cause | |||
if dut.facts["asic_type"] == "vs": | |||
cause = re.search("User issued '(.*)' command", cause).groups()[0] | |||
match = re.search("User issued '(.*)' command", cause) |
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.
@yutongzhang-microsoft since KVM prints something like this for "show reboot-cause" on the first boot -
Unknown (First boot of SONiC version master.597250-dc3c0451b)
The above regex User issued ...
won't match the above string. Won't you need one more regex Unknown (\(.*\))
to match the above?
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.
Because, the pattern User issued '(.*)' command
will get the real reboot reason in the position of (.*)
, such as warm-reboot, fast-reboot. But if we get the string Unknown (First boot of SONiC version master.597250-dc3c0451b)
, we can't match the cause of dict reboot_ctrl_dict
in this file. So I think just return REBOOT_TYPE_UNKNOWN
makes sence.
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.
Thank you I see what you mean. LGTM
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.
LGTM
What is the motivation for this PR? There is another reboot cause Unknown (First boot of SONiC version xxx) on kvm besides User issued xxx' command, which will cause error 'NoneType' object has no attribute 'groups' based on the current code. To address this, this PR suggests a conditional check to ensure that the match object is not None before attempting to access its 'groups' attribute, thereby preventing such issue. How did you do it? This PR suggests a conditional check to ensure that the match object is not None before attempting to access its 'groups' attribute, thereby preventing such issue. How did you verify/test it?
What is the motivation for this PR? There is another reboot cause Unknown (First boot of SONiC version xxx) on kvm besides User issued xxx' command, which will cause error 'NoneType' object has no attribute 'groups' based on the current code. To address this, this PR suggests a conditional check to ensure that the match object is not None before attempting to access its 'groups' attribute, thereby preventing such issue. How did you do it? This PR suggests a conditional check to ensure that the match object is not None before attempting to access its 'groups' attribute, thereby preventing such issue. How did you verify/test it?
Description of PR
There is another reboot cause
Unknown (First boot of SONiC version xxx)
on kvm besidesUser issued xxx' command
, which will cause error'NoneType' object has no attribute 'groups'
based on the current code. To address this, this PR suggests a conditional check to ensure that the match object is not None before attempting to access its 'groups' attribute, thereby preventing such issue.Summary:
Fixes # (13979
)
Type of change
Back port request
Approach
What is the motivation for this PR?
There is another reboot cause
Unknown (First boot of SONiC version xxx)
on kvm besidesUser issued xxx' command
, which will cause error'NoneType' object has no attribute 'groups'
based on the current code. To address this, this PR suggests a conditional check to ensure that the match object is not None before attempting to access its 'groups' attribute, thereby preventing such issue.How did you do it?
This PR suggests a conditional check to ensure that the match object is not None before attempting to access its 'groups' attribute, thereby preventing such issue.
How did you verify/test it?
Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation