Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discover NVMe TCP addresses individually #302

Merged
merged 4 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/dell/gofsutil v1.14.0
github.com/dell/goiscsi v1.8.0
github.com/dell/gonvme v1.6.0
github.com/dell/gopowerstore v1.14.0
github.com/dell/gopowerstore v1.14.1-0.20240123112046-ec40aaf31242
github.com/fsnotify/fsnotify v1.7.0
github.com/go-openapi/strfmt v0.21.3
github.com/golang/mock v1.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ github.com/dell/goiscsi v1.8.0 h1:kocGVOdgnufc6eGpfmwP66hyhY7OVgIafaS/+uM6ogU=
github.com/dell/goiscsi v1.8.0/go.mod h1:PTlQGJaGKYgia95mGwwHSBgvfOr3BfLIjGNh1HT6p+s=
github.com/dell/gonvme v1.6.0 h1:Y/g0Ml8E3oSB+bqGJN1/U+V621h9t0KJeYAF5aQ7NVU=
github.com/dell/gonvme v1.6.0/go.mod h1:/UgJAlR03LbPSDIK2BfhiYUlzyY7lAMJ6ao8eYab2Eg=
github.com/dell/gopowerstore v1.14.0 h1:j4wSn25X2AH2t3/ySNPHmNWjqM0zHDkYyDPt+0uE8cc=
github.com/dell/gopowerstore v1.14.0/go.mod h1:YH3SpMX2dr3ouYWWPhk5lzjip3aaVVksFOSoenRDY5w=
github.com/dell/gopowerstore v1.14.1-0.20240123112046-ec40aaf31242 h1:kR8Opp5Rr3syF5uJnmDJNe94QrUbqmLXsjTDrENFG88=
github.com/dell/gopowerstore v1.14.1-0.20240123112046-ec40aaf31242/go.mod h1:YH3SpMX2dr3ouYWWPhk5lzjip3aaVVksFOSoenRDY5w=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
Expand Down
28 changes: 26 additions & 2 deletions pkg/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func GetLogFields(ctx context.Context) log.Fields {
return fields
}

// GetISCSITargetsInfoFromStorage returns list of gobrick compatible iscsi tragets by querying PowerStore array
// GetISCSITargetsInfoFromStorage returns list of gobrick compatible iscsi targets by querying PowerStore array
func GetISCSITargetsInfoFromStorage(client gopowerstore.Client, volumeApplianceID string) ([]gobrick.ISCSITargetInfo, error) {
addrInfo, err := client.GetStorageISCSITargetAddresses(context.Background())
if err != nil {
Expand All @@ -319,7 +319,31 @@ func GetISCSITargetsInfoFromStorage(client gopowerstore.Client, volumeApplianceI
return result, nil
}

// GetFCTargetsInfoFromStorage returns list of gobrick compatible FC tragets by querying PowerStore array
// GetNVMETCPTargetsInfoFromStorage returns list of gobrick compatible NVME TCP targets by querying PowerStore array
func GetNVMETCPTargetsInfoFromStorage(client gopowerstore.Client, volumeApplianceID string) ([]gobrick.NVMeTargetInfo, error) {
clusterInfo, err := client.GetCluster(context.Background())
nvmeNQN := clusterInfo.NVMeNQN

addrInfo, err := client.GetStorageNVMETCPTargetAddresses(context.Background())
if err != nil {
log.Error(err.Error())
return []gobrick.NVMeTargetInfo{}, err
}
// sort data by id
sort.Slice(addrInfo, func(i, j int) bool {
return addrInfo[i].ID < addrInfo[j].ID
})
var result []gobrick.NVMeTargetInfo
for _, t := range addrInfo {
// volumeApplianceID will be empty in case the call is from NodeGetInfo
if t.ApplianceID == volumeApplianceID || volumeApplianceID == "" {
result = append(result, gobrick.NVMeTargetInfo{Target: nvmeNQN, Portal: fmt.Sprintf("%s:4420", t.Address)})
}
}
return result, nil
}

// GetFCTargetsInfoFromStorage returns list of gobrick compatible FC targets by querying PowerStore array
func GetFCTargetsInfoFromStorage(client gopowerstore.Client, volumeApplianceID string) ([]gobrick.FCTargetInfo, error) {
fcPorts, err := client.GetFCPorts(context.Background())
if err != nil {
Expand Down
11 changes: 11 additions & 0 deletions pkg/common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ func TestGetISCSITargetsInfoFromStorage(t *testing.T) {
})
}

func TestGetNVMETCPTargetsInfoFromStorage(t *testing.T) {
t.Run("api error", func(t *testing.T) {
e := errors.New("some error")
clientMock := new(gopowerstoremock.Client)
clientMock.On("GetCluster", context.Background()).Return(gopowerstore.Cluster{}, e)
clientMock.On("GetStorageNVMETCPTargetAddresses", context.Background()).Return([]gopowerstore.IPPoolAddress{}, e)
_, err := common.GetNVMETCPTargetsInfoFromStorage(clientMock, "A1")
assert.EqualError(t, err, e.Error())
})
}

func TestGetFCTargetsInfoFromStorage(t *testing.T) {
t.Run("api error", func(t *testing.T) {
e := errors.New("some error")
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -746,11 +746,11 @@ func GetServiceTag(ctx context.Context, req *csi.CreateVolumeRequest, arr *array
if err != nil {
log.Warn("Received error while calling GetNAS ", err.Error())
}
if nas.CurrentNodeId == "" {
if nas.CurrentNodeID == "" {
log.Warn("Unable to fetch the CurrentNodeId from the nas server")
} else {
// Removing "-node-X" from the end of CurrentNodeId to get Appliance Name
applianceName = strings.Split(nas.CurrentNodeId, "-node-")[0]
applianceName = strings.Split(nas.CurrentNodeID, "-node-")[0]
// Fetching appliance information using the appliance name
ap, err = arr.Client.GetApplianceByName(ctx, applianceName)
if err != nil {
Expand Down
Loading
Loading