Fix search pattern for PD-NVMe devices in findAvailableDevFsPaths
pwschuurman opened this issue · 0 comments
Discovered by @w-michal
Context: code at https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/blob/master/pkg/deviceutils/device-utils.go added with b614d93
filepath.Glob(diskNvmePattern)
in findAvailableDevFsPaths
can return all NVMe related paths, not just drive paths:
/dev/nvme0n1p15 <- partition path
/dev/nvme0n1p14 <- partition path
/dev/nvme0n1p1 <- partition path
/dev/nvme0n1 <- drive/namespace path
/dev/nvme0 <- device path
All paths from findAvailableDevFsPaths
are forwarded to getDevFsSerial
function. But google_nvme_id
called inside getNvmeSerial
can fail with non-drive paths and result in confusing error log-spam, see b/295545421
diskNvmePattern
should be updated from /dev/nvme*
to /dev/nvme*n*
or /dev/nvme[0-9]n[0-9]*
to avoid iterating over partition paths (I don't know GO, and documentation at https://pkg.go.dev/path/filepath#Glob is not very helpful).