diff --git a/pkg/clusterd/disk.go b/pkg/clusterd/disk.go index b23f444e1..a747daf7f 100644 --- a/pkg/clusterd/disk.go +++ b/pkg/clusterd/disk.go @@ -168,6 +168,12 @@ 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) + } + 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 ae631bd8f..c798498b9 100644 --- a/pkg/util/sys/device.go +++ b/pkg/util/sys/device.go @@ -97,6 +97,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 @@ -208,11 +210,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 } @@ -236,6 +239,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 }