From 8c1bf0f3f0460e5fcb699d5c911978330cdc8729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Mon, 9 May 2022 12:02:48 +0200 Subject: [PATCH 1/3] core: append filesystem property on disk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When detecting the device property the filesystem was not passed but used later to validate if the device should be taken or not. Now we read the filesystem info from "lsblk" and populate it in the device type. Closes: https://github.com/rook/rook/issues/9470 Signed-off-by: Sébastien Han --- pkg/clusterd/disk.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/clusterd/disk.go b/pkg/clusterd/disk.go index 306bb629f..0478798dd 100644 --- a/pkg/clusterd/disk.go +++ b/pkg/clusterd/disk.go @@ -166,6 +166,9 @@ func PopulateDeviceInfo(d string, executor exec.Executor) (*sys.LocalDisk, error if val, ok := diskProps["KNAME"]; ok { disk.KernelName = path.Base(val) } + if val, ok := diskProps["FSTYPE"]; ok && val != "" { + disk.Filesystem = path.Base(val) + } return disk, nil } From 77b2e10c140e4b4dea44b7dc28900f6fb8f15258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Mon, 9 May 2022 12:06:35 +0200 Subject: [PATCH 2/3] core: add more debug info to the prepare pod MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When running the device property commands, let's also log their results for better debugging/visibility. Signed-off-by: Sébastien Han --- pkg/util/sys/device.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/util/sys/device.go b/pkg/util/sys/device.go index fc96c07e2..d6aab1f9b 100644 --- a/pkg/util/sys/device.go +++ b/pkg/util/sys/device.go @@ -206,11 +206,12 @@ func GetDeviceProperties(device string, executor exec.Executor) (map[string]stri // GetDevicePropertiesFromPath gets a device property from a path func GetDevicePropertiesFromPath(devicePath string, executor exec.Executor) (map[string]string, error) { output, err := executor.ExecuteCommandWithOutput("lsblk", devicePath, - "--bytes", "--nodeps", "--pairs", "--paths", "--output", "SIZE,ROTA,RO,TYPE,PKNAME,NAME,KNAME") + "--bytes", "--nodeps", "--pairs", "--paths", "--output", "SIZE,ROTA,RO,TYPE,PKNAME,NAME,KNAME,MOUNTPOINT,FSTYPE") if err != nil { logger.Errorf("failed to execute lsblk. output: %s", output) return nil, err } + logger.Debugf("lsblk output: %q", output) return parseKeyValuePairString(output), nil } @@ -234,6 +235,7 @@ func GetUdevInfo(device string, executor exec.Executor) (map[string]string, erro if err != nil { return nil, err } + logger.Debugf("udevadm info output: %q", output) return parseUdevInfo(output), nil } From 8328ec6d313b20362d33031eb8d0c4992307b1ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Mon, 9 May 2022 12:07:48 +0200 Subject: [PATCH 3/3] core: add mountpoint detection to the prepare pod MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Amount various filters let's add a mountpoint property and skip the device if its filesystem is mounted. Signed-off-by: Sébastien Han --- pkg/clusterd/disk.go | 3 +++ pkg/daemon/ceph/osd/daemon.go | 6 ++++++ pkg/util/sys/device.go | 2 ++ 3 files changed, 11 insertions(+) diff --git a/pkg/clusterd/disk.go b/pkg/clusterd/disk.go index 0478798dd..d675422cf 100644 --- a/pkg/clusterd/disk.go +++ b/pkg/clusterd/disk.go @@ -169,6 +169,9 @@ func PopulateDeviceInfo(d string, executor exec.Executor) (*sys.LocalDisk, error if val, ok := diskProps["FSTYPE"]; ok && val != "" { disk.Filesystem = path.Base(val) } + if val, ok := diskProps["MOUNTPOINT"]; ok && val != "" { + disk.Mountpoint = path.Base(val) + } return disk, nil } diff --git a/pkg/daemon/ceph/osd/daemon.go b/pkg/daemon/ceph/osd/daemon.go index a5513d00c..ea52bda24 100644 --- a/pkg/daemon/ceph/osd/daemon.go +++ b/pkg/daemon/ceph/osd/daemon.go @@ -296,6 +296,12 @@ func getAvailableDevices(context *clusterd.Context, agent *OsdAgent) (*DeviceOsd continue } + // Add detection for mounted device and skip if mounted + if device.Mountpoint != "" { + logger.Infof("skipping device %q with mountpoint %q", device.Name, device.Mountpoint) + continue + } + // Ignore device with filesystem signature since c-v inventory // cannot detect that correctly // see: https://tracker.ceph.com/issues/43585 diff --git a/pkg/util/sys/device.go b/pkg/util/sys/device.go index d6aab1f9b..3525b0c91 100644 --- a/pkg/util/sys/device.go +++ b/pkg/util/sys/device.go @@ -95,6 +95,8 @@ type LocalDisk struct { Partitions []Partition // Filesystem is the filesystem currently on the device Filesystem string `json:"filesystem"` + // Mountpoint is the mountpoint of the filesystem's on the device + Mountpoint string `json:"mountpoint"` // Vendor is the device vendor Vendor string `json:"vendor"` // Model is the device model