Match nvme-eui zpool member references to physical disks

A pool built from /dev/disk/by-id/nvme-eui.<hex> references (the
installer's device naming when identical NVMe models share a box)
produced no serial key in the disk-to-pool matcher, and the WWN lookup
never stripped the eui. prefix smartctl reports, so the disk fell back
to the generic Proxmox usage string and showed 'ZFS' instead of its
pool name while an identically-built node showed 'local-zfs' (issue
#1540).
This commit is contained in:
rcourtman
2026-07-14 14:48:30 +01:00
parent d7a73ee521
commit 4dcc18fbd4
2 changed files with 23 additions and 0 deletions
@@ -74,6 +74,7 @@ func (a *diskPoolAssignment) lookup(disk models.PhysicalDisk) string {
}
wwn := strings.ToLower(strings.TrimSpace(disk.WWN))
wwn = strings.TrimPrefix(wwn, "0x")
wwn = strings.TrimPrefix(wwn, "eui.")
if wwn != "" {
if pool, ok := a.serialPool[wwn]; ok {
return pool
@@ -197,6 +198,12 @@ func serialFromByID(raw string) string {
if idx := strings.LastIndex(name, "-part"); idx > 0 {
name = name[:idx]
}
// NVMe pools are often built from nvme-eui.<hex> references (the
// installer's pick when identical models share a box); the hex is the
// device's WWN/EUI, which smartctl reports as "eui.<hex>" or "0x<hex>".
if strings.HasPrefix(name, "nvme-eui.") {
return strings.TrimPrefix(name, "nvme-eui.")
}
// The last underscore-separated token is typically the serial.
if idx := strings.LastIndex(name, "_"); idx > 0 {
return name[idx+1:]
@@ -34,6 +34,12 @@ func TestDiskPoolAssignmentLookup(t *testing.T) {
{Name: "wwn-0x50014ee2123456ab", Leaf: 1},
},
},
{
Name: "flash",
Devices: []proxmox.ZFSPoolDevice{
{Name: "/dev/disk/by-id/nvme-eui.0025385b91501234-part3", Leaf: 1},
},
},
}
assignment := buildDiskPoolAssignment(pools)
@@ -48,6 +54,16 @@ func TestDiskPoolAssignmentLookup(t *testing.T) {
disk: models.PhysicalDisk{DevPath: "/dev/sda", Serial: "S5Y2NX0R500001Z"},
want: "rpool",
},
{
label: "nvme-eui by-id leaf matches disk WWN in eui form",
disk: models.PhysicalDisk{DevPath: "/dev/nvme0n1", WWN: "eui.0025385B91501234"},
want: "flash",
},
{
label: "nvme-eui by-id leaf matches disk WWN in 0x form",
disk: models.PhysicalDisk{DevPath: "/dev/nvme0n1", WWN: "0x0025385b91501234"},
want: "flash",
},
{
label: "short leaf name matches partition-stripped devpath",
disk: models.PhysicalDisk{DevPath: "/dev/sdc"},