Skip to content

pmdalmsensors, qa/1480: handle sensor read failures gracefully - #2689

Merged
natoscott merged 1 commit into
performancecopilot:mainfrom
natoscott:sensors-qa
Aug 11, 2026
Merged

pmdalmsensors, qa/1480: handle sensor read failures gracefully#2689
natoscott merged 1 commit into
performancecopilot:mainfrom
natoscott:sensors-qa

Conversation

@natoscott

Copy link
Copy Markdown
Member

When sensors -j is called for a specific chip (e.g. NVMe) and the device returns EAGAIN, the empty or invalid output causes json.loads() to raise an exception, crashing the fetch callback. Catch JSON parse errors during fetch and preserve the last known sensor values instead.

At init time (no chip filter), re-raise the exception so the PMDA fails loudly rather than silently starting with zero metrics.

Also harden the QA test: ensure the awk sum is always numeric so _within_tolerance does not receive empty arguments.

Relates: #2665

When sensors -j is called for a specific chip (e.g. NVMe) and the
device returns EAGAIN, the empty or invalid output causes json.loads()
to raise an exception, crashing the fetch callback. Catch JSON parse
errors during fetch and preserve the last known sensor values instead.

At init time (no chip filter), re-raise the exception so the PMDA
fails loudly rather than silently starting with zero metrics.

Also harden the QA test: ensure the awk sum is always numeric so
_within_tolerance does not receive empty arguments.

Relates: performancecopilot#2665

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 4f25ba9e-4143-4b4c-bd4d-41cef6043f9d

📥 Commits

Reviewing files that changed from the base of the PR and between 32cb4b1 and 5b519c5.

📒 Files selected for processing (2)
  • qa/1480
  • src/pmdas/lmsensors/pmdalmsensors.python

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved PMDA value aggregation so accumulated totals are consistently reported as numeric values, including zero.
    • Improved sensor data handling by separating output decoding from JSON parsing.
    • Chip-specific parsing failures now fail gracefully without interrupting sensor collection, while broader parsing errors continue to be reported.

Walkthrough

The PR updates PMDA numeric aggregation and changes lmsensors JSON parsing so chip-specific failures return silently while top-level failures propagate.

Changes

PMDA aggregation

Layer / File(s) Summary
Normalize aggregated output
qa/1480
The PMDA aggregation expression outputs sum + 0 instead of sum.

lmsensors parsing

Layer / File(s) Summary
Handle lmsensors JSON parsing errors
src/pmdas/lmsensors/pmdalmsensors.python
lmsensors_get decodes subprocess output before JSON parsing. Chip-specific JSON failures return without raising, while top-level failures are re-raised.

Possibly related PRs

Poem

A rabbit checks the sensor stream,
And sums each value bright and clean.
Bad chip data slips away,
While top-level errors choose to stay.
Zero joins the final score—
Hop, hop, safer than before!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the affected PMDA and the main change: graceful handling of sensor read failures.
Description check ✅ Passed The description accurately explains fetch-time error handling, initialization behavior, QA hardening, and the related issue.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@natoscott
natoscott merged commit 5b519c5 into performancecopilot:main Aug 11, 2026
17 checks passed
@natoscott
natoscott deleted the sensors-qa branch August 11, 2026 02:06
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.

1 participant