Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Classify SATA disks behind a SAS HBA as SATA

rcourtman25b2df07a029
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index e57875e729..264dabcdf2 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -2174,6 +2174,17 @@ Agent` secondary handoff against the live setup wizard instead of relying
`internal/api/rbac_handlers_test.go`, and the rejection cases in
`pkg/auth/sqlite_manager_test.go`.
+23. Linux SMART transport classification tests vendor before bus address.
+ Vendor `ATA` is the SCSI layer's marker for a device reached through a SAT
+ translation layer, so it is the more specific signal; a genuine SAS disk
+ reports its own vendor and never `ATA`. SATA disks behind an LSI/mpt3sas HBA
+ (the common Unraid and TrueNAS layout) expose `sas_address` on their
+ scsi_device while reporting vendor `ATA`, so testing `sas_address` first
+ classified them as SAS, which drops the `-d sat` probe hint and steers them
+ back to the `-d scsi` probe the discovery work exists to avoid. Regression
+ coverage: `TestSATABehindSASControllerClassifiesAsSATA` in
+ `internal/hostagent/issue1595_sas_collection_test.go`.
+
## Current State
### PBS connection health does not create agent lifecycle evidence
diff --git a/internal/hostagent/issue1595_sas_collection_test.go b/internal/hostagent/issue1595_sas_collection_test.go
index 1fdd11c44e..6f1db2f994 100644
--- a/internal/hostagent/issue1595_sas_collection_test.go
+++ b/internal/hostagent/issue1595_sas_collection_test.go
@@ -270,3 +270,81 @@ func issue1595DeviceFromSysfsPath(path string) string {
}
return remainder
}
+
+// TestSATABehindSASControllerClassifiesAsSATA pins the transport precedence for
+// the common Unraid and TrueNAS layout: SATA disks hanging off an LSI/mpt3sas
+// HBA. Those expose sas_address on their scsi_device while reporting vendor
+// "ATA", which is the SCSI layer's marker for a device reached through a SAT
+// translation layer. Classifying them as SAS makes
+// linuxInferredSmartctlDeviceTypes return only "scsi" and discards the correct
+// "-d sat" hint, steering the disk back to the "-d scsi" probe that 6e93cb3b5
+// exists to avoid.
+func TestSATABehindSASControllerClassifiesAsSATA(t *testing.T) {
+ origRead := smartctlReadFile
+ origEval := smartctlEvalSymlinks
+ origGOOS := runtimeGOOS
+ t.Cleanup(func() {
+ smartctlReadFile = origRead
+ smartctlEvalSymlinks = origEval
+ runtimeGOOS = origGOOS
+ })
+ runtimeGOOS = "linux"
+ smartctlEvalSymlinks = func(string) (string, error) { return "", fs.ErrNotExist }
+
+ for _, tc := range []struct {
+ name string
+ files map[string]string
+ want string
+ }{
+ {
+ name: "sata disk behind an HBA reports both sas_address and vendor ATA",
+ files: map[string]string{
+ "/sys/block/sdb/device/sas_address": "0x4433221105000000",
+ "/sys/block/sdb/device/vendor": "ATA",
+ },
+ want: "sata",
+ },
+ {
+ name: "genuine sas disk reports its own vendor",
+ files: map[string]string{
+ "/sys/block/sdb/device/sas_address": "0x5000c500a1b2c3d4",
+ "/sys/block/sdb/device/vendor": "SEAGATE",
+ },
+ want: "sas",
+ },
+ {
+ name: "direct sata disk with no sas_address",
+ files: map[string]string{
+ "/sys/block/sdb/device/vendor": "ATA",
+ },
+ want: "sata",
+ },
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ smartctlReadFile = func(path string) ([]byte, error) {
+ if value, ok := tc.files[filepath.ToSlash(path)]; ok {
+ return []byte(value), nil
+ }
+ return nil, fs.ErrNotExist
+ }
+ if got := linuxBlockDeviceTransportEvidence("sdb"); got != tc.want {
+ t.Fatalf("transport = %q, want %q", got, tc.want)
+ }
+ })
+ }
+
+ // The probe hint must follow the classification, not just the label.
+ smartctlReadFile = func(path string) ([]byte, error) {
+ switch filepath.ToSlash(path) {
+ case "/sys/block/sdb/device/sas_address":
+ return []byte("0x4433221105000000"), nil
+ case "/sys/block/sdb/device/vendor":
+ return []byte("ATA"), nil
+ }
+ return nil, fs.ErrNotExist
+ }
+ types := linuxInferredSmartctlDeviceTypes(smartctlTarget{Path: "/dev/sdb"})
+ if len(types) == 0 || types[0] != "sat" {
+ t.Fatalf("inferred device types = %v, want the sat hint first", types)
+ }
+}
diff --git a/internal/hostagent/smartctl.go b/internal/hostagent/smartctl.go
index f72bd57112..d1b2354a76 100644
--- a/internal/hostagent/smartctl.go
+++ b/internal/hostagent/smartctl.go
@@ -1073,12 +1073,19 @@ func linuxBlockDeviceTransportEvidence(block string) string {
resolvedTransport = "sata"
}
}
- if readTrimmedFile(filepath.Join("/sys/block", block, "device", "sas_address")) != "" {
- return "sas"
- }
+ // Vendor "ATA" is the SCSI layer's marker for an ATA device reached through
+ // a SAT translation layer, so it is the more specific signal and must be
+ // tested first. A SATA disk behind an LSI/mpt3sas HBA (the common Unraid
+ // and TrueNAS layout) exposes sas_address on its scsi_device while still
+ // reporting vendor ATA; checking sas_address first classified those as SAS,
+ // which drops the -d sat probe hint and steers them back to the -d scsi
+ // probe. A genuine SAS disk reports its own vendor, never "ATA".
if strings.EqualFold(readTrimmedFile(filepath.Join("/sys/block", block, "device", "vendor")), "ATA") {
return "sata"
}
+ if readTrimmedFile(filepath.Join("/sys/block", block, "device", "sas_address")) != "" {
+ return "sas"
+ }
if resolvedTransport != "" {
return resolvedTransport
}