[202012] Backport Enhance ssd_generic with more error handling to avoid python crash #273
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.
Signed-off-by: Kebo Liu [email protected]
Description
Backport #271 to 202012
Judge the
self._parse_re
return value, if it'sN/A
then stop further string slice handling to avoid a crash.Update the regular expression pattern for Innodisk SSD health, to handle the case that the output of the health section is different when its lifetime reaches the end.
Motivation and Context
Original code doesn't handle the case that
self._parse_re
returnsN/A
, it's assuming thatself._parse_re
will always return anone N/A
value thus further handling the result w/o judge, which could in a crash.On Innodisk SSD, when the SSD remaining lifetime reaches the end, the output of the
Health
section will be a number w/o%
, e.g.Health: 0.00
instead ofHealth: 95.0%
in the normal case, need to update the regular expression to handle this case.How Has This Been Tested?
Additional Information (Optional)