support for rook Device.FullPath

Signed-off-by: Dmitry Yusupov <dmitry.yusupov@nexenta.com>
This commit is contained in:
Dmitry Yusupov committed 2019-07-03 23:06:58 -07:00
1 parent 004f795a79
commit 5ffe2f037c
4 files changed
+23 -3

No files matched your search

+1
View File
@@ -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`).
+1 -1
View File
@@ -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"`
}
+18 -1
View File
@@ -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])
}
+3 -1
View File
@@ -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