diff --git a/pkg/util/initiator.go b/pkg/util/initiator.go index 0377897..548893e 100644 --- a/pkg/util/initiator.go +++ b/pkg/util/initiator.go @@ -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{ @@ -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 { @@ -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 { diff --git a/pkg/util/jsonrpc.go b/pkg/util/jsonrpc.go index 9cd84e7..da2b5b3 100644 --- a/pkg/util/jsonrpc.go +++ b/pkg/util/jsonrpc.go @@ -22,6 +22,7 @@ import ( "errors" "fmt" "net/http" + "strconv" "strings" "k8s.io/klog" @@ -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 { @@ -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 }