fix(agent): honor explicit SMART_DEVICES type hint instead of scan-detected type#2102
Open
BootstrapperSBL wants to merge 1 commit into
Open
fix(agent): honor explicit SMART_DEVICES type hint instead of scan-detected type#2102BootstrapperSBL wants to merge 1 commit into
BootstrapperSBL wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2072.
Problem
When
SMART_DEVICESspecifies an explicit device type (e.g./dev/sda:scsi), the agent parses and resolves the type correctly, butsmartctlArgsintentionally omits the-dflag forscsi/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 satfails with exit status 2 and SMART collection never succeeds, even though/dev/sda:scsiwas configured precisely to avoid that.Fix
Track whether a device type came from an explicit
SMART_DEVICES:typehint (DeviceInfo.explicitType) and always pass it to smartctl via-d. Scan-detectedscsi/atatypes are still left off so smartctl can auto-detect them, preserving the #1345 behavior. The flag is threaded throughmergeDeviceListsso it survives both config merges and verified-device rescans.Before / After
For
SMART_DEVICES=/dev/sda:scsiwheresmartctl --scanreports/dev/sdaassat:smartctl -a --json=c /dev/sda→ smartctl auto-detectssat→ exit status 2, no data.smartctl -d scsi -a --json=c /dev/sda→ correct type used, data collected.Tests
TestSmartctlArgsExplicitType— explicitscsi/ataget-d; scan-detectedscsistill 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 vetclean.