Conversation
redfish_api_get_firmware_version() took its return code from curl's exit status alone. exec_curl_cmd() special-cases only HTTP 401, so a device answering "no such inventory member" came back as ERR_CODE_OK: the body carries a Redfish error object rather than a 'Version' key, so the function logged an error and returned the 'N/A' it started from. A caller cannot tell that apart from a device whose version is genuinely unknown. One that probes several candidate IDs to find the one its device carries stops at the first, because every ID reports success. Inspect the error body and return ERR_CODE_URI_NOT_FOUND for a missing resource. The code spelling varies by implementation: an SPC6 BMC answers HTTP 400 with Base.1.19.ResourceMissingAtURI, others use ResourceNotFound, so accept either and keep anything else a loud ERR_CODE_GENERIC_ERROR. Log the missing member at notice rather than error. Probing an ID a device does not carry is a normal step of resolution; logging it at error level makes a healthy device emit an ERR line on every query, which is enough to trip log scanners that treat ERR as a failure. The mock body in the added test is a verbatim error response from an SPC6 BMC, so the code and HTTP status under test are what a real device sends.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why I did it
redfish_api_get_firmware_version()derives its return code from curl's exit status alone.exec_curl_cmd()special-cases only HTTP 401, so a device that answers "no such inventory member" comes back asERR_CODE_OK: the response body carries a Redfish error object instead of aVersionkey, so the function logs an error and returns the'N/A'it started from.A caller cannot distinguish that from a device whose version is genuinely unknown. In particular, a caller that probes several candidate IDs to find the one its device carries stops at the first ID, because every ID reports success.
Observed on an SPC6 BMC, querying an inventory member it does not have:
A second effect is log noise: the miss is logged at error level, so a healthy device emits an
ERRline on every query. That is enough to trip log scanners that treatERRas a failure signal.How I did it
Inspect the Redfish error body in
redfish_api_get_firmware_version():ERR_CODE_URI_NOT_FOUNDand is logged at notice level, since probing an ID a device does not carry is a normal step of resolution rather than a fault;ERR_CODE_GENERIC_ERRORand stays logged at error level.The code spelling varies by implementation — the SPC6 BMC above answers
Base.1.19.ResourceMissingAtURI, while other implementations useResourceNotFound— so both are accepted.How to verify it
pytest tests/redfish_client_test.py— 78 passed.Two tests are added, both driven through the public API:
test_get_bmc_version_missing_inventory_member— assertsERR_CODE_URI_NOT_FOUND. Fails without the change withassert 0 == -9.test_get_bmc_version_unrecognized_error— asserts an unrecognised error code still returnsERR_CODE_GENERIC_ERROR, so real failures are not reclassified as "absent". Fails without the change withassert 0 == -12.The mock body in
mock_get_bmc_info_missing_responseis a verbatim error response captured from an SPC6 BMC, so the error code and HTTP status under test are the ones a real device sends.Verified on hardware: with this behaviour, probing
FW_BMC_0on a device that carriesMGX_FW_BMC_0reports the member as missing and the caller resolves to the ID the device actually has.Description for the changelog
Return
ERR_CODE_URI_NOT_FOUNDwhen a Redfish firmware inventory member does not exist, instead ofERR_CODE_OKwith a version ofN/A.