Skip to content
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 regression from #71. #74

Merged
merged 4 commits into from
Apr 29, 2024

Conversation

chanchiwai-ray
Copy link
Contributor

@chanchiwai-ray chanchiwai-ray commented Apr 29, 2024

Set the "Health" key to a string of "NA" when it's falsy (e.g. None, "").

Note:

d.get("key") or "NA"  # return NA if d = {"key": <falsy-value>}
d.get("key", "NA")     # return None if d = {"key": <falsy-value>}

If "Health" is None, it can cause the following error:

AttributeError: ("'NoneType' object has no attribute 'replace'", Metric(redfish_storage_controller, Storage Controller information obtained from redfish., info, , [Sample(name='redfish_storage_controller_info', labels={'system_id': 'System.Embedded.1', 'storage_id': 'AHCI.Embedded.1-1', 'controller_id': '0', 'health': None, 'state': 'Enabled'}, value=1, timestamp=None, exemplar=None)]))

Set the "Health" key to a string of "NA" when it's not present.
@sudeephb
Copy link
Contributor

Can you add a unit test covering the scenario where "Health" is not present?

@chanchiwai-ray chanchiwai-ray requested a review from sudeephb April 29, 2024 01:43
Copy link
Contributor

@sudeephb sudeephb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM

@chanchiwai-ray
Copy link
Contributor Author

Sorry, @sudeephb @jneo8 I added one more test case, can you check again ?

Copy link
Contributor

@dashmage dashmage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one tiny nit on the comment, LGTM!

prometheus_hardware_exporter/collectors/redfish.py Outdated Show resolved Hide resolved
Co-authored-by: Ashley James <ashleyjames2800@gmail.com>
@chanchiwai-ray chanchiwai-ray merged commit 6495fe2 into canonical:main Apr 29, 2024
3 checks passed
@chanchiwai-ray chanchiwai-ray deleted the bug/regression-71 branch April 29, 2024 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants