Skip to content

Commit

Permalink
use ctrl-loss-tmo and reconnect-delay value from controlplane (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffrey1330 authored Dec 13, 2024
1 parent ca9a6a3 commit 8e94681
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
28 changes: 16 additions & 12 deletions pkg/util/initiator.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ func NewSpdkCsiInitiator(volumeContext map[string]string, spdkNode *NodeNVMf) (S
}
return &initiatorNVMf{
// see util/nvmf.go VolumeInfo()
targetType: volumeContext["targetType"],
connections: connections,
nqn: volumeContext["nqn"],
model: volumeContext["model"],
client: *spdkNode.client,
targetType: volumeContext["targetType"],
connections: connections,
nqn: volumeContext["nqn"],
reconnectDelay: volumeContext["reconnectDelay"],
ctrlLossTmo: volumeContext["ctrlLossTmo"],
model: volumeContext["model"],
client: *spdkNode.client,
}, nil
case "cache":
return &initiatorCache{
Expand All @@ -74,11 +76,13 @@ func NewSpdkCsiInitiator(volumeContext map[string]string, spdkNode *NodeNVMf) (S

// NVMf initiator implementation
type initiatorNVMf struct {
targetType string
connections []connectionInfo
nqn string
model string
client RPCClient
targetType string
connections []connectionInfo
nqn string
reconnectDelay string
ctrlLossTmo string
model string
client RPCClient
}

type initiatorCache struct {
Expand Down Expand Up @@ -264,8 +268,8 @@ func (nvmf *initiatorNVMf) Connect() (string, error) {
for _, conn := range nvmf.connections {
cmdLine := []string{
"nvme", "connect", "-t", strings.ToLower(nvmf.targetType),
"-a", conn.IP, "-s", strconv.Itoa(conn.Port), "-n", nvmf.nqn, "-l", "600",
"-c", "1",
"-a", conn.IP, "-s", strconv.Itoa(conn.Port), "-n", nvmf.nqn, "-l", nvmf.ctrlLossTmo,
"-c", nvmf.reconnectDelay,
}
err := execWithTimeoutRetry(cmdLine, 40, len(nvmf.connections))
if err != nil {
Expand Down
25 changes: 15 additions & 10 deletions pkg/util/jsonrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"errors"
"fmt"
"net/http"
"strconv"
"strings"

"k8s.io/klog"
Expand Down Expand Up @@ -106,10 +107,12 @@ type LvStore struct {
}

type LvolConnectResp struct {
Nqn string `json:"nqn"`
Port int `json:"port"`
IP string `json:"ip"`
Connect string `json:"connect"`
Nqn string `json:"nqn"`
ReconnectDelay int `json:"reconnect-delay"`
CtrlLossTmo int `json:"ctrl-loss-tmo"`
Port int `json:"port"`
IP string `json:"ip"`
Connect string `json:"connect"`
}

type connectionInfo struct {
Expand Down Expand Up @@ -282,12 +285,14 @@ func (client *RPCClient) getVolumeInfo(lvolID string) (map[string]string, error)
}

return map[string]string{
"name": lvolID,
"uuid": lvolID,
"nqn": result[0].Nqn,
"model": lvolID,
"targetType": "tcp",
"connections": string(connectionsData),
"name": lvolID,
"uuid": lvolID,
"nqn": result[0].Nqn,
"reconnectDelay": strconv.Itoa(result[0].ReconnectDelay),
"ctrlLossTmo": strconv.Itoa(result[0].CtrlLossTmo),
"model": lvolID,
"targetType": "tcp",
"connections": string(connectionsData),
}, nil
}

Expand Down

0 comments on commit 8e94681

Please sign in to comment.