get_disks() no longer reports a failed read as "no disks", and tells a failed smartctl call apart from a disk without SMART.
lsblk: a failed or garbled lsblk -J (empty output, sudo: …, an lsblk error, JSON that is not a device list) raises CommandErrorException with the output's tail. [] now only means lsblk listed no disk.
/proc/mdstat: a failed read raises instead of silently dropping every disk's pool. A host without the md driver (no /proc/mdstat) still has no members.
smartctl: the call goes through _sudo_status, so the exit status is known. A transport error (timeout) or an exit status with bit 0 or 1 set (command line not parsed — sudo's own refusal exits 1 as well — or device not opened) is logged at warning level with host, disk and reason; the disk stays in the inventory as unknown. The disk-state bits 2–7 are not a failed call: a disk that fails its verdict (bit 3) still reads failed, without a warning in the log. PhysicalDiskDict has no per-disk error field, so "reported per disk" would be a contract change; the warning log is the option the issue names.
warning health: a disk whose verdict passed but that counts lost or unreadable sectors reads warning, as the contract (healthy/warning/failed/unknown) allows:
ATA: raw value > 0 of Reallocated_Sector_Ct (5), Current_Pending_Sector (197) or Offline_Uncorrectable (198);
NVMe: Critical Warning ≠ 0x00, or Media and Data Integrity Errors > 0;
SAS: Elements in grown defect list > 0.
A failed verdict outranks the counters.
get_disks shrinks (lsblk read moved into _lsblk), so its two baseline entries are tightened (lines 87 → 83, complexity 12 → 11).
netOrk
netOrk's poll (netork/jobs/tasks/poll/_collect.py, the storage loop) catches each storage getter's exception and logs get_disks() failed: …; the other storage parts are still collected. The UI's storage tab already colours warning (yellow).
Tests
Fixtures only, reusing the recorded smartctl -iHA outputs (ATA SATA DOM, NVMe, SAS, QEMU) from #15. No degraded disk was at hand, so the warning cases put a count in place of a recorded zero in those recordings (as the existing FAILED! case does for the verdict). Red first: the new parser cases, the lsblk/mdstat failures and the two smartctl warning tests failed against main. pytest (70 passed), ruff format/check, mypy (no errors in the package), napalm-standard check and ratchet green; coverage 62.5 % (floor 15).
## What
`get_disks()` no longer reports a failed read as "no disks", and tells a failed `smartctl` call apart from a disk without SMART.
- **lsblk**: a failed or garbled `lsblk -J` (empty output, `sudo: …`, an lsblk error, JSON that is not a device list) raises `CommandErrorException` with the output's tail. `[]` now only means lsblk listed no disk.
- **/proc/mdstat**: a failed read raises instead of silently dropping every disk's pool. A host without the md driver (no `/proc/mdstat`) still has no members.
- **smartctl**: the call goes through `_sudo_status`, so the exit status is known. A transport error (timeout) or an exit status with bit 0 or 1 set (command line not parsed — sudo's own refusal exits 1 as well — or device not opened) is logged at **warning** level with host, disk and reason; the disk stays in the inventory as `unknown`. The disk-state bits 2–7 are not a failed call: a disk that fails its verdict (bit 3) still reads `failed`, without a warning in the log. `PhysicalDiskDict` has no per-disk error field, so "reported per disk" would be a contract change; the warning log is the option the issue names.
- **`warning` health**: a disk whose verdict passed but that counts lost or unreadable sectors reads `warning`, as the contract (`healthy`/`warning`/`failed`/`unknown`) allows:
- ATA: raw value > 0 of `Reallocated_Sector_Ct` (5), `Current_Pending_Sector` (197) or `Offline_Uncorrectable` (198);
- NVMe: `Critical Warning` ≠ `0x00`, or `Media and Data Integrity Errors` > 0;
- SAS: `Elements in grown defect list` > 0.
A failed verdict outranks the counters.
`get_disks` shrinks (lsblk read moved into `_lsblk`), so its two baseline entries are tightened (lines 87 → 83, complexity 12 → 11).
## netOrk
netOrk's poll (`netork/jobs/tasks/poll/_collect.py`, the storage loop) catches each storage getter's exception and logs `get_disks() failed: …`; the other storage parts are still collected. The UI's storage tab already colours `warning` (yellow).
## Tests
Fixtures only, reusing the recorded `smartctl -iHA` outputs (ATA SATA DOM, NVMe, SAS, QEMU) from #15. No degraded disk was at hand, so the `warning` cases put a count in place of a recorded zero in those recordings (as the existing `FAILED!` case does for the verdict). Red first: the new parser cases, the lsblk/mdstat failures and the two smartctl warning tests failed against main. pytest (70 passed), ruff format/check, mypy (no errors in the package), `napalm-standard check` and `ratchet` green; coverage 62.5 % (floor 15).
Closes #16
get_disks swallowed a failed or garbled lsblk and returned [], the
answer for a NAS without disks, so every disk vanished on a transient
error. It now raises CommandErrorException; a failed /proc/mdstat read
raises too instead of dropping every pool.
A smartctl call that timed out, was refused by sudo or could not open
the device was logged at debug level and read like a disk without
SMART. It is now logged as a warning with the reason (exit status bits
0 and 1; the disk-state bits 2-7 are not a failed call).
A disk whose verdict passed but that counts reallocated, pending or
offline-uncorrectable sectors (ATA), grown defects (SAS), or sets a
critical warning or counts media errors (NVMe) is reported as
"warning", as the contract allows.
get_disks shrinks below its baseline entries, which are tightened.
Closes#16
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What
get_disks()no longer reports a failed read as "no disks", and tells a failedsmartctlcall apart from a disk without SMART.lsblk -J(empty output,sudo: …, an lsblk error, JSON that is not a device list) raisesCommandErrorExceptionwith the output's tail.[]now only means lsblk listed no disk./proc/mdstat) still has no members._sudo_status, so the exit status is known. A transport error (timeout) or an exit status with bit 0 or 1 set (command line not parsed — sudo's own refusal exits 1 as well — or device not opened) is logged at warning level with host, disk and reason; the disk stays in the inventory asunknown. The disk-state bits 2–7 are not a failed call: a disk that fails its verdict (bit 3) still readsfailed, without a warning in the log.PhysicalDiskDicthas no per-disk error field, so "reported per disk" would be a contract change; the warning log is the option the issue names.warninghealth: a disk whose verdict passed but that counts lost or unreadable sectors readswarning, as the contract (healthy/warning/failed/unknown) allows:Reallocated_Sector_Ct(5),Current_Pending_Sector(197) orOffline_Uncorrectable(198);Critical Warning≠0x00, orMedia and Data Integrity Errors> 0;Elements in grown defect list> 0.A failed verdict outranks the counters.
get_disksshrinks (lsblk read moved into_lsblk), so its two baseline entries are tightened (lines 87 → 83, complexity 12 → 11).netOrk
netOrk's poll (
netork/jobs/tasks/poll/_collect.py, the storage loop) catches each storage getter's exception and logsget_disks() failed: …; the other storage parts are still collected. The UI's storage tab already colourswarning(yellow).Tests
Fixtures only, reusing the recorded
smartctl -iHAoutputs (ATA SATA DOM, NVMe, SAS, QEMU) from #15. No degraded disk was at hand, so thewarningcases put a count in place of a recorded zero in those recordings (as the existingFAILED!case does for the verdict). Red first: the new parser cases, the lsblk/mdstat failures and the two smartctl warning tests failed against main. pytest (70 passed), ruff format/check, mypy (no errors in the package),napalm-standard checkandratchetgreen; coverage 62.5 % (floor 15).Closes #16