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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Strip nvme namespace suffixes in the server disk-to-pool matcher
rcourtmanea524c9229cd
diff --git a/internal/monitoring/physical_disk_pool_membership.go b/internal/monitoring/physical_disk_pool_membership.goindex 209317309f..7f38710918 100644--- a/internal/monitoring/physical_disk_pool_membership.go+++ b/internal/monitoring/physical_disk_pool_membership.go@@ -204,6 +204,9 @@ func serialFromByID(raw string) string {if strings.HasPrefix(name, "nvme-eui.") {return strings.TrimPrefix(name, "nvme-eui.")}+ // systemd's nvme by-id links can carry a trailing _<n> namespace suffix+ // (nvme-MODEL_SERIAL_1); the serial is the token before it (#1540).+ name = stripNVMeNamespaceSuffix(name)// The last underscore-separated token is typically the serial.if idx := strings.LastIndex(name, "_"); idx > 0 {return name[idx+1:]@@ -217,6 +220,28 @@ func serialFromByID(raw string) string {return ""}+// stripNVMeNamespaceSuffix removes the trailing _<n> namespace token systemd+// appends to nvme by-id link names (nvme-MODEL_SERIAL_1). Only short all-digit+// tokens are stripped, and only when another underscore token remains, so a+// genuine serial is never truncated.+func stripNVMeNamespaceSuffix(name string) string {+ if !strings.HasPrefix(name, "nvme-") {+ return name+ }+ idx := strings.LastIndex(name, "_")+ if idx <= 0 {+ return name+ }+ suffix := name[idx+1:]+ if len(suffix) == 0 || len(suffix) > 3 || !allDigits(suffix) {+ return name+ }+ if !strings.Contains(name[:idx], "_") {+ return name+ }+ return name[:idx]+}+func allDigits(s string) bool {for i := 0; i < len(s); i++ {if !isDigit(s[i]) {diff --git a/internal/monitoring/physical_disk_pool_membership_test.go b/internal/monitoring/physical_disk_pool_membership_test.goindex 4cebdf6cc3..2a766cf4b9 100644--- a/internal/monitoring/physical_disk_pool_membership_test.go+++ b/internal/monitoring/physical_disk_pool_membership_test.go@@ -40,6 +40,14 @@ func TestDiskPoolAssignmentLookup(t *testing.T) {{Name: "/dev/disk/by-id/nvme-eui.0025385b91501234-part3", Leaf: 1},},},+ {+ Name: "local-zfs",+ Devices: []proxmox.ZFSPoolDevice{+ // systemd nvme by-id link with a trailing _1 namespace suffix,+ // as reported on #1540's pve01.+ {Name: "/dev/disk/by-id/nvme-Samsung_SSD_990_PRO_4TB_S7DPNF0Y316714T_1-part1", Leaf: 1},+ },+ },}assignment := buildDiskPoolAssignment(pools)@@ -64,6 +72,11 @@ func TestDiskPoolAssignmentLookup(t *testing.T) {disk: models.PhysicalDisk{DevPath: "/dev/nvme0n1", WWN: "0x0025385b91501234"},want: "flash",},+ {+ label: "nvme by-id leaf with namespace suffix matches disk serial",+ disk: models.PhysicalDisk{DevPath: "/dev/nvme2n1", Serial: "S7DPNF0Y316714T"},+ want: "local-zfs",+ },{label: "short leaf name matches partition-stripped devpath",disk: models.PhysicalDisk{DevPath: "/dev/sdc"},