From 4dcc18fbd41ef201370678ff48505b6a40853786 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Tue, 14 Jul 2026 14:48:30 +0100 Subject: [PATCH] Match nvme-eui zpool member references to physical disks A pool built from /dev/disk/by-id/nvme-eui. 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). --- .../monitoring/physical_disk_pool_membership.go | 7 +++++++ .../physical_disk_pool_membership_test.go | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/internal/monitoring/physical_disk_pool_membership.go b/internal/monitoring/physical_disk_pool_membership.go index 1d4add882..209317309 100644 --- a/internal/monitoring/physical_disk_pool_membership.go +++ b/internal/monitoring/physical_disk_pool_membership.go @@ -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. references (the + // installer's pick when identical models share a box); the hex is the + // device's WWN/EUI, which smartctl reports as "eui." or "0x". + 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:] diff --git a/internal/monitoring/physical_disk_pool_membership_test.go b/internal/monitoring/physical_disk_pool_membership_test.go index 7addc6d50..4cebdf6cc 100644 --- a/internal/monitoring/physical_disk_pool_membership_test.go +++ b/internal/monitoring/physical_disk_pool_membership_test.go @@ -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"},