Naudit / pystorcli2

Python library provides wrapper around storcli tool to manage and control LSI MegaRAID controllers.
BSD 3-Clause "New" or "Revised" License
2 stars 7 forks source link

INVALID_STATUS text is not really correct #17

Closed ulmitov closed 1 year ago

ulmitov commented 1 year ago

Hi, Regarding this code in error.py INVALID_STATUS = ( 255, '', 'Invalid status - used for polling command completion.')

It is a a bit misleading, not sure if 255 is same for all cases but i got this one:

storcli64 /c0/e252/s7 set good J
{
"Controllers":[
{
    "Command Status" : {
        "CLI Version" : "007.2408.0000.0000 Nov 15, 2022",
        "Operating system" : "Linux 5.15.0-25-generic",
        "Controller" : 0,
        "Status" : "Failure",
        "Description" : "Set Drive Good Failed.",
        "Detailed Status" : [
            {
                "Drive" : "/c0/e252/s7",
                "Status" : "Failure",
                "ErrCd" : 255,
                "ErrMsg" : "Operation not allowed."
            }
        ]
    }
}
]
}
ulmitov commented 1 year ago

While in python i get this line, which is misleading: pystorcli.exc.StorCliCmdErrorCode: Command '/usr/sbin/storcli64 /c0/e252/s7 set good J' error: 255 (Invalid status - used for polling command completion.)

Maybe for 255 better to print the error as is

ralequi commented 1 year ago

hi @ulmitov !

I was in vacations, sorry for the delay. Did you find anything more about why that "Invalid status - used for polling command completion" is happening ?

ulmitov commented 1 year ago

Hey @ralequi ! Well, i do not know why my drive fails to run "/c0/e252/s7 set good". But the "Invalid status - used for polling command completion" is coming from pystorcli/errors.py line 353. I do not know what is the origin of this text "used for polling command completion". Usually for 255 is see storcli returns "Operation not allowed." So suggesting to change that text in error.py, or print the error text that comes from storcli...

ulmitov commented 1 year ago

Correction, just caught another example:

root@ubuntu22-cuda:~# storcli64 /c0 /bbu show all J
{
"Controllers":[
{
    "Command Status" : {
        "CLI Version" : "007.2408.0000.0000 Nov 15, 2022",
        "Operating system" : "Linux 5.15.0-25-generic",
        "Controller" : 0,
        "Status" : "Failure",
        "Description" : "None",
        "Detailed Status" : [
            {
                "Ctrl" : 0,
                "Status" : "Failed",
                "Property" : "-",
                "ErrMsg" : "use /cx/cv",
                "ErrCd" : 255
            }
        ]
    }
}
]
}

For 255 the error message will be different each time, depends what storcli returns

ralequi commented 1 year ago

Nice point!

I'm going to do your suggestion.

In the other hand... what show says about your drive? Is unused, jbod or inside a raid? Maybe it is "trully" broken?

ulmitov commented 1 year ago

The drive state is UBUnsp, also smartctl shows an error, going to replace it

ralequi commented 1 year ago

Pushed to develop/master

ulmitov commented 1 year ago

verified the fix, thanks!!