From 5ffe2f037c438df825c2fc5e3705c8a6917aeb29 Mon Sep 17 00:00:00 2001 From: Dmitry Yusupov Date: Sat, 29 Jun 2019 20:16:50 -0700 Subject: [PATCH] support for rook Device.FullPath Signed-off-by: Dmitry Yusupov --- Documentation/edgefs-cluster-crd.md | 1 + pkg/apis/rook.io/v1alpha2/types.go | 2 +- pkg/operator/discover/discover.go | 19 ++++++++++++++++++- pkg/operator/edgefs/cluster/target/layout.go | 4 +++- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Documentation/edgefs-cluster-crd.md b/Documentation/edgefs-cluster-crd.md index f171c457a..2b3be139e 100644 --- a/Documentation/edgefs-cluster-crd.md +++ b/Documentation/edgefs-cluster-crd.md @@ -120,6 +120,7 @@ Below are the settings available, both at the cluster and individual node level, - `^[^r]`: Selects all devices that do *not* start with `r` - `devices`: A list of individual device names belonging to this node to include in the storage cluster. Mixing of `devices` and `directories` on the same node isn't supported. - `name`: The name of the device (e.g., `sda`). + - `fullpath`: The full path to the device (e.g., `/dev/disk/by-id/scsi-35000c5008335c83f`). If specified then `name` can be omitted. - `config`: Device-specific config settings. See the [config settings](#target-configuration-settings) below. - `directories`: A list of directory paths on the nodes that will be included in the storage cluster. Note that using two directories on the same physical device can cause a negative performance impact. Mixing of `devices` and `directories` on the same node isn't supported. Since EdgeFS is leveraging StatefulSet, directories can only be defined at cluster level. - `path`: The path on disk of the directory (e.g., `/rook/storage-dir`). diff --git a/pkg/apis/rook.io/v1alpha2/types.go b/pkg/apis/rook.io/v1alpha2/types.go index 1abf7a800..a17a9eccf 100644 --- a/pkg/apis/rook.io/v1alpha2/types.go +++ b/pkg/apis/rook.io/v1alpha2/types.go @@ -46,7 +46,7 @@ type Node struct { type Device struct { Name string `json:"name,omitempty"` - FullPath string // TODO: FullPath to be supported for devices + FullPath string `json:"fullpath,omitempty"` Config map[string]string `json:"config"` } diff --git a/pkg/operator/discover/discover.go b/pkg/operator/discover/discover.go index 7ab46aafe..53ec5ddac 100644 --- a/pkg/operator/discover/discover.go +++ b/pkg/operator/discover/discover.go @@ -22,6 +22,7 @@ import ( "fmt" "os" "regexp" + "strings" "time" "github.com/coreos/pkg/capnslog" @@ -298,6 +299,16 @@ func ListDevicesInUse(context *clusterd.Context, namespace, nodeName string) ([] return devices, nil } +func matchDeviceFullPath(devLinks, fullpath string) bool { + dlsArr := strings.Split(devLinks, " ") + for i := range dlsArr { + if dlsArr[i] == fullpath { + return true + } + } + return false +} + // GetAvailableDevices conducts outer join using input filters with free devices that a node has. It marks the devices from join result as in-use. func GetAvailableDevices(context *clusterd.Context, nodeName, clusterName string, devices []rookalpha.Device, filter string, useAllDevices bool) ([]rookalpha.Device, error) { results := []rookalpha.Device{} @@ -337,7 +348,13 @@ func GetAvailableDevices(context *clusterd.Context, nodeName, clusterName string if len(devices) > 0 { for i := range devices { for j := range nodeDevices { - if devices[i].Name == nodeDevices[j].Name { + if devices[i].FullPath != "" && matchDeviceFullPath(nodeDevices[j].DevLinks, devices[i].FullPath) { + if devices[i].Name == "" { + devices[i].Name = nodeDevices[j].Name + } + results = append(results, devices[i]) + claimedDevices = append(claimedDevices, nodeDevices[j]) + } else if devices[i].Name == nodeDevices[j].Name { results = append(results, devices[i]) claimedDevices = append(claimedDevices, nodeDevices[j]) } diff --git a/pkg/operator/edgefs/cluster/target/layout.go b/pkg/operator/edgefs/cluster/target/layout.go index 62d246669..506321ec0 100644 --- a/pkg/operator/edgefs/cluster/target/layout.go +++ b/pkg/operator/edgefs/cluster/target/layout.go @@ -52,11 +52,13 @@ func CreateQualifiedHeadlessServiceName(replicaNum int, namespace string) string return fmt.Sprintf("%s-%d.%s.%s", appName, replicaNum, appName, namespace) } +// EdgeFS RT-RD driver needs SCSI-3, ATA, NVMe by-id link func getIdDevLinkName(dls string) (dl string) { dlsArr := strings.Split(dls, " ") for i := range dlsArr { s := strings.Replace(dlsArr[i], "/dev/disk/by-id/", "", 1) - if strings.Contains(s, "/") || strings.Contains(s, "wwn-") { + // if result contains "/" then it is not by-id, so skip it + if strings.Contains(s, "/") || strings.Contains(s, "wwn-") || strings.Contains(s, "nvme-nvme.") || strings.Contains(s, "nvme-eui.") { continue } dl = s