mirror of
https://github.com/kubernetes-csi/csi-driver-nvmf.git
synced 2025-05-02 05:03:18 +00:00
feat: add rdma support
Signed-off-by: Meinhard Zhou <zhouenhua@bytedance.com>
This commit is contained in:
parent
998801c53d
commit
b002568227
@ -99,8 +99,6 @@ func (d *driver) AddControllerServiceCapabilities(cl []csi.ControllerServiceCapa
|
|||||||
}
|
}
|
||||||
|
|
||||||
d.cscap = csc
|
d.cscap = csc
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *driver) ValidateControllerServiceRequest(c csi.ControllerServiceCapability_RPC_Type) error {
|
func (d *driver) ValidateControllerServiceRequest(c csi.ControllerServiceCapability_RPC_Type) error {
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
b64 "encoding/base64"
|
b64 "encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -70,7 +69,7 @@ func _connect(argStr string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// todo: read file to verify
|
// todo: read file to verify
|
||||||
lines, err := utils.ReadLinesFromFile(file)
|
lines, _ := utils.ReadLinesFromFile(file)
|
||||||
klog.Infof("Connect: read string %s", lines)
|
klog.Infof("Connect: read string %s", lines)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -182,7 +181,7 @@ func disconnectByNqn(nqn, hostnqn string) int {
|
|||||||
|
|
||||||
// delete nqn directory if has no hostnqn files
|
// delete nqn directory if has no hostnqn files
|
||||||
nqnPath := filepath.Join(RUN_NVMF, nqn)
|
nqnPath := filepath.Join(RUN_NVMF, nqn)
|
||||||
hostnqns, err := ioutil.ReadDir(nqnPath)
|
hostnqns, err := os.ReadDir(nqnPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("Disconnect: readdir %s err: %v", nqnPath, err)
|
klog.Errorf("Disconnect: readdir %s err: %v", nqnPath, err)
|
||||||
return -ENOENT
|
return -ENOENT
|
||||||
@ -191,7 +190,7 @@ func disconnectByNqn(nqn, hostnqn string) int {
|
|||||||
os.RemoveAll(nqnPath)
|
os.RemoveAll(nqnPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
devices, err := ioutil.ReadDir(SYS_NVMF)
|
devices, err := os.ReadDir(SYS_NVMF)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("Disconnect: readdir %s err: %s", SYS_NVMF, err)
|
klog.Errorf("Disconnect: readdir %s err: %s", SYS_NVMF, err)
|
||||||
return -ENOENT
|
return -ENOENT
|
||||||
@ -204,7 +203,7 @@ func disconnectByNqn(nqn, hostnqn string) int {
|
|||||||
|
|
||||||
// disconnect all controllers if has no hostnqn files
|
// disconnect all controllers if has no hostnqn files
|
||||||
if len(hostnqns) <= 0 {
|
if len(hostnqns) <= 0 {
|
||||||
devices, err := ioutil.ReadDir(SYS_NVMF)
|
devices, err := os.ReadDir(SYS_NVMF)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("Disconnect: readdir %s err: %s", SYS_NVMF, err)
|
klog.Errorf("Disconnect: readdir %s err: %s", SYS_NVMF, err)
|
||||||
return -ENOENT
|
return -ENOENT
|
||||||
@ -328,7 +327,7 @@ func removeConnectorFile(targetPath string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetConnectorFromFile(filePath string) (*Connector, error) {
|
func GetConnectorFromFile(filePath string) (*Connector, error) {
|
||||||
f, err := ioutil.ReadFile(filePath)
|
f, err := os.ReadFile(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &Connector{}, err
|
return &Connector{}, err
|
||||||
|
|
||||||
|
@ -120,6 +120,10 @@ func (n *NodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVo
|
|||||||
scanPath := parseDeviceToControllerPath(deviceName)
|
scanPath := parseDeviceToControllerPath(deviceName)
|
||||||
if utils.IsFileExisting(scanPath) {
|
if utils.IsFileExisting(scanPath) {
|
||||||
file, err := os.OpenFile(scanPath, os.O_RDWR|os.O_TRUNC, 0766)
|
file, err := os.OpenFile(scanPath, os.O_RDWR|os.O_TRUNC, 0766)
|
||||||
|
if err != nil {
|
||||||
|
klog.Errorf("NodeExpandVolume: open scan path %s error: %v", scanPath, err)
|
||||||
|
return nil, status.Errorf(codes.Internal, "NodeExpandVolume: open scan path %s error: %v", scanPath, err)
|
||||||
|
}
|
||||||
err = utils.WriteStringToFile(file, "1")
|
err = utils.WriteStringToFile(file, "1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("NodeExpandVolume: Rescan error: %v", err)
|
klog.Errorf("NodeExpandVolume: Rescan error: %v", err)
|
||||||
|
@ -62,7 +62,7 @@ func getNVMfDiskInfo(req *csi.NodePublishVolumeRequest) (*nvmfDiskInfo, error) {
|
|||||||
nqn := volOpts["nqn"]
|
nqn := volOpts["nqn"]
|
||||||
|
|
||||||
if targetTrAddr == "" || nqn == "" || targetTrPort == "" || targetTrType == "" || deviceUUID == "" {
|
if targetTrAddr == "" || nqn == "" || targetTrPort == "" || targetTrType == "" || deviceUUID == "" {
|
||||||
return nil, fmt.Errorf("Some Nvme target info is missing, volID: %s ", volName)
|
return nil, fmt.Errorf("some nvme target info is missing, volID: %s ", volName)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &nvmfDiskInfo{
|
return &nvmfDiskInfo{
|
||||||
|
@ -32,15 +32,10 @@ import (
|
|||||||
|
|
||||||
func waitForPathToExist(devicePath string, maxRetries, intervalSeconds int, deviceTransport string) (bool, error) {
|
func waitForPathToExist(devicePath string, maxRetries, intervalSeconds int, deviceTransport string) (bool, error) {
|
||||||
for i := 0; i < maxRetries; i++ {
|
for i := 0; i < maxRetries; i++ {
|
||||||
if deviceTransport == "tcp" {
|
|
||||||
exist := utils.IsFileExisting(devicePath)
|
exist := utils.IsFileExisting(devicePath)
|
||||||
if exist {
|
if exist {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return false, fmt.Errorf("connect only support tcp")
|
|
||||||
}
|
|
||||||
|
|
||||||
if i == maxRetries-1 {
|
if i == maxRetries-1 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,6 @@ type nonBlockingGRPCServer struct {
|
|||||||
func (s *nonBlockingGRPCServer) Start(endpoint string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer) {
|
func (s *nonBlockingGRPCServer) Start(endpoint string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer) {
|
||||||
s.wg.Add(1)
|
s.wg.Add(1)
|
||||||
go s.serve(endpoint, ids, cs, ns)
|
go s.serve(endpoint, ids, cs, ns)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *nonBlockingGRPCServer) Wait() {
|
func (s *nonBlockingGRPCServer) Wait() {
|
||||||
|
Loading…
Reference in New Issue
Block a user