-
Notifications
You must be signed in to change notification settings - Fork 9
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 issue in integration about smartctl and return error code 4 #43
Conversation
I can also be a little bit more restrictive and check that return code from run_command is either 0 or 4 and failed if it is not the case. |
I'd be more confortable with that yeah. |
645faf1
to
f741e78
Compare
297d79b
to
b699c04
Compare
06ff29e
to
e5928ed
Compare
@@ -24,7 +24,7 @@ def get_information(session, args): | |||
with OperationLocker(): | |||
disks = _list_disks() | |||
for disk in disks: | |||
cmd = run_command(["smartctl", "-j", "-a", disk]) | |||
cmd = run_command(["smartctl", "-j", "-a", disk], check=False) | |||
results[disk] = json.loads(cmd['stdout']) |
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.
Does smartctl always output JSON, even when there's an error? And what about stderr in case the command failed?
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.
I still would have checked the return code, and whenever the return code differs from 0 and 4, replace result[disk] with something which contains the return code, raw stdout and stderr (but just for the affected disks). That's why I'd also check with XO so that we know how they would handle this case. Do they display the JSON, uninterpreted? Do they look for specific pieces of information?
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.
but we are already returning stdout that contains the error.
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.
they just display the raw json (and we see the error code in it)
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.
Ok, this, the man page and a test I made gives me all I wanted to know: it wraps the call to "regular" smartctl and apparently always puts the result inside JSON, even when there are non-recoverable errors (unless there's an error generating the JSON itself, I guess).
See this example where I gave it a non recognised argument:
smartctl -j -a --wrongarg /dev/sdb
{
"json_format_version": [
1,
0
],
"smartctl": {
"version": [
7,
0
],
"svn_revision": "4883",
"platform_info": "x86_64-linux-4.19.0+1",
"build_info": "(local build)",
"argv": [
"smartctl",
"-j",
"-a",
"--wrongarg",
"/dev/sdb"
],
"messages": [
{
"string": "=======> UNRECOGNIZED OPTION: wrongarg",
"severity": "error"
}
],
"exit_status": 1
}
}
So 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.
Nitpick: "Some device doesn't support SMART capability" => "Some devices don't support SMART capability(ies?)", in the commit message.
I followed the error message reported by smartctl: |
But I think that SMART is the capability of monitoring and reporting disks status |
Some devices don't support SMART capability and getting information from such devices returns an error code 4. As it happens in CI we remove the check of the return code knowing that this error code is a field of the JSON output. Signed-off-by: Guillaume <[email protected]>
e5928ed
to
d4b8cd6
Compare
Some device doesn't support SMART capability and getting information from such device returns an error code 4. As it happens in CI we remove the check of the return code.