Skip to content

fix(agent): honor explicit SMART_DEVICES type hint instead of scan-detected type#2102

Open
BootstrapperSBL wants to merge 1 commit into
henrygd:mainfrom
BootstrapperSBL:fix/smart-devices-explicit-type
Open

fix(agent): honor explicit SMART_DEVICES type hint instead of scan-detected type#2102
BootstrapperSBL wants to merge 1 commit into
henrygd:mainfrom
BootstrapperSBL:fix/smart-devices-explicit-type

Conversation

@BootstrapperSBL

Copy link
Copy Markdown
Contributor

Fixes #2072.

Problem

When SMART_DEVICES specifies an explicit device type (e.g. /dev/sda:scsi), the agent parses and resolves the type correctly, but smartctlArgs intentionally omits the -d flag for scsi/ata — a workaround for scan misdetection (#1345). That workaround also discards an explicit user-provided type, so smartctl falls back to auto-detection and picks the wrong type (sat). On USB drives whose bridge chip doesn't support SAT/ATA passthrough, -d sat fails with exit status 2 and SMART collection never succeeds, even though /dev/sda:scsi was configured precisely to avoid that.

Fix

Track whether a device type came from an explicit SMART_DEVICES :type hint (DeviceInfo.explicitType) and always pass it to smartctl via -d. Scan-detected scsi/ata types are still left off so smartctl can auto-detect them, preserving the #1345 behavior. The flag is threaded through mergeDeviceLists so it survives both config merges and verified-device rescans.

Before / After

For SMART_DEVICES=/dev/sda:scsi where smartctl --scan reports /dev/sda as sat:

  • Before: smartctl -a --json=c /dev/sda → smartctl auto-detects sat → exit status 2, no data.
  • After: smartctl -d scsi -a --json=c /dev/sda → correct type used, data collected.

Tests

  • TestSmartctlArgsExplicitType — explicit scsi/ata get -d; scan-detected scsi still doesn't.
  • TestSmartDevicesExplicitTypeFlowsToSmartctlArgs — full parse → merge → args regression for this issue.
  • TestMergeDeviceListsPreservesExplicitTypeAcrossRescan — the explicit flag survives a rescan.

All three fail without the fix and pass with it. go test -tags=testing ./... for the smart suite passes; gofmt/go vet clean.

…tected type

When SMART_DEVICES specifies an explicit type (e.g. /dev/sda:scsi), the
agent resolved the device type correctly but smartctlArgs dropped the -d
flag for scsi/ata (the henrygd#1345 scan-misdetection workaround), so smartctl
re-detected the wrong type (sat) and collection failed on USB drives
whose bridge does not support SAT passthrough.

Mark types that come from an explicit SMART_DEVICES hint and always pass
them through via -d, while still letting scan-detected scsi/ata
auto-detect as before. Adds regression tests for the arg building, the
full parse -> merge -> args path, and flag preservation across rescans.

Fixes henrygd#2072

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@BootstrapperSBL BootstrapperSBL requested a review from henrygd as a code owner June 27, 2026 13:24
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.

[Bug]: SMART_DEVICES type hint ignored — agent uses smartctl --scan result instead, causing USB drive SMART collection to fail

1 participant