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

Recreate sdr cache if invalid #70

Merged
merged 3 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion prometheus_hardware_exporter/collectors/ipmi_sel.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ def get_sel_entries(self, time_range: int) -> Optional[List[Dict[str, str]]]:
Returns:
sel_entries: a list of dictionaries containing sel_sentries, or []
"""
result = self("--output-event-state --interpret-oem-data --entity-sensor-names")
# --sdr-cache-recreate is required to automatically recreate the SDR cache in case it is
# out of date or invalid. Without this, the service will stop getting ipmi-sel data if the
# cache is out of date.
result = self(
"--sdr-cache-recreate --output-event-state --interpret-oem-data --entity-sensor-names"
jneo8 marked this conversation as resolved.
Show resolved Hide resolved
)
if result.error:
logger.error(result.error)
return None
Expand Down
5 changes: 4 additions & 1 deletion prometheus_hardware_exporter/collectors/ipmimonitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ def get_sensor_data(self) -> List[Dict[str, str]]:
Returns:
sensor_data: a list of dictionaries containing sensor data, or []
"""
result = self()
# --sdr-cache-recreate is required to automatically recreate the SDR cache in case it is
# out of date or invalid. Without this, the service will stop getting sensor data if the
# cache is out of date.
result = self("--sdr-cache-recreate")
if result.error:
logger.error(result.error)
return []
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/test_ipmi_sel.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def test_00_get_sel_entries_success(self, mock_call):
ipmi_sel = IpmiSel(config)
payloads = ipmi_sel.get_sel_entries(24 * 60 * 60)
expected_sel_entries = SAMPLE_SEL_ENTRIES
mock_call.assert_called_with(
"--sdr-cache-recreate --output-event-state --interpret-oem-data --entity-sensor-names" # noqa: E501
)
self.assertEqual(payloads, expected_sel_entries)

@patch.object(Command, "__call__")
Expand All @@ -59,6 +62,9 @@ def test_01_get_sel_entries_zero_records(self, mock_call):
config = Config()
ipmi_sel = IpmiSel(config)
payloads = ipmi_sel.get_sel_entries(300)
mock_call.assert_called_with(
"--sdr-cache-recreate --output-event-state --interpret-oem-data --entity-sensor-names"
)
self.assertEqual(payloads, [])

@patch.object(Command, "__call__")
Expand All @@ -67,4 +73,7 @@ def test_02_get_sel_entries_error(self, mock_call):
config = Config()
ipmi_sel = IpmiSel(config)
payloads = ipmi_sel.get_sel_entries(300)
mock_call.assert_called_with(
"--sdr-cache-recreate --output-event-state --interpret-oem-data --entity-sensor-names"
)
self.assertEqual(payloads, None)
2 changes: 2 additions & 0 deletions tests/unit/test_ipmimonitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def test_00_get_sensor_data_success(self, mock_call):
ipmimonitoring = IpmiMonitoring(config)
payloads = ipmimonitoring.get_sensor_data()
expected_sensor_entries = SAMPLE_SENSOR_ENTRIES
mock_call.assert_called_with("--sdr-cache-recreate")
self.assertEqual(payloads, expected_sensor_entries)

@patch.object(Command, "__call__")
Expand All @@ -56,4 +57,5 @@ def test_00_get_sensor_data_error(self, mock_call):
config = Config()
ipmimonitoring = IpmiMonitoring(config)
payloads = ipmimonitoring.get_sensor_data()
mock_call.assert_called_with("--sdr-cache-recreate")
self.assertEqual(payloads, [])
Loading