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

fix(storage/backend): adjust nvme to parent member. #410

Merged
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 @@ -10,7 +10,7 @@ require (
github.com/lithammer/fuzzysearch v1.1.8
github.com/onsi/ginkgo/v2 v2.14.0
github.com/onsi/gomega v1.30.0
github.com/opiproject/opi-api v0.0.0-20231204182835-b9900483c605
github.com/opiproject/opi-api v0.0.0-20231211154947-aee3998dd0c2
github.com/spf13/cobra v1.8.0
github.com/stretchr/testify v1.8.4
go.einride.tech/aip v0.66.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ github.com/opiproject/opi-api v0.0.0-20231127063346-b9b53584ef18 h1:6CYdU51sDuW+
github.com/opiproject/opi-api v0.0.0-20231127063346-b9b53584ef18/go.mod h1:92pv4ulvvPMuxCJ9ND3aYbmBfEMLx0VCjpkiR7ZTqPY=
github.com/opiproject/opi-api v0.0.0-20231204182835-b9900483c605 h1:3buAwkHHsEMjn+cIUOTi7RLcG8n3/52UNm8pZ8tZOJI=
github.com/opiproject/opi-api v0.0.0-20231204182835-b9900483c605/go.mod h1:92pv4ulvvPMuxCJ9ND3aYbmBfEMLx0VCjpkiR7ZTqPY=
github.com/opiproject/opi-api v0.0.0-20231211154947-aee3998dd0c2 h1:sWvDPuYS6Kbke3k5rpD46kHhGx//rBKMw3Z1/mDZxdk=
github.com/opiproject/opi-api v0.0.0-20231211154947-aee3998dd0c2/go.mod h1:92pv4ulvvPMuxCJ9ND3aYbmBfEMLx0VCjpkiR7ZTqPY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
Expand Down
21 changes: 10 additions & 11 deletions storage/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
}
newResourceID = parsed.String()
}
fullname := resourceIDToVolumeName(newResourceID)
fullname := resourceIDToRemoteControllerName(newResourceID)

Check warning on line 80 in storage/backend.go

View check run for this annotation

Codecov / codecov/patch

storage/backend.go#L80

Added line #L80 was not covered by tests
if rr0.Name != fullname {
return fmt.Errorf("server filled value '%s' is not matching user requested '%s'", rr0.Name, fullname)
}
Expand All @@ -88,7 +88,7 @@
return err
}
log.Printf("Reset Nvme: %v", rr2)
rr3, err := c4.ListNvmeRemoteControllers(ctx, &pb.ListNvmeRemoteControllersRequest{Parent: "todo"})
rr3, err := c4.ListNvmeRemoteControllers(ctx, &pb.ListNvmeRemoteControllersRequest{})

Check warning on line 91 in storage/backend.go

View check run for this annotation

Codecov / codecov/patch

storage/backend.go#L91

Added line #L91 was not covered by tests
if err != nil {
return err
}
Expand Down Expand Up @@ -150,11 +150,11 @@

for _, resourceID := range []string{"opi-nvme8-path", ""} {
np0, err := c5.CreateNvmePath(ctx, &pb.CreateNvmePathRequest{
Parent: rr0.Name,

Check warning on line 153 in storage/backend.go

View check run for this annotation

Codecov / codecov/patch

storage/backend.go#L153

Added line #L153 was not covered by tests
NvmePathId: resourceID,
NvmePath: &pb.NvmePath{
Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TCP,
Traddr: addr[0].String(),
ControllerNameRef: rr0.Name,
Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TCP,
Traddr: addr[0].String(),

Check warning on line 157 in storage/backend.go

View check run for this annotation

Codecov / codecov/patch

storage/backend.go#L156-L157

Added lines #L156 - L157 were not covered by tests
Fabrics: &pb.FabricsPath{
Adrfam: pb.NvmeAddressFamily_NVME_ADRFAM_IPV4,
Trsvcid: int64(port),
Expand All @@ -175,18 +175,17 @@
}
newResourceID = parsed.String()
}
fullname := resourceIDToVolumeName(newResourceID)
fullname := resourceIDToNvmePathName(ctrlrResourceID, newResourceID)

Check warning on line 178 in storage/backend.go

View check run for this annotation

Codecov / codecov/patch

storage/backend.go#L178

Added line #L178 was not covered by tests
if np0.Name != fullname {
return fmt.Errorf("server filled value '%s' is not matching user requested '%s'", np0.Name, fullname)
}
log.Printf("Created Nvme path: %v", np0)
np3, err := c5.UpdateNvmePath(ctx, &pb.UpdateNvmePathRequest{
UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"*"}},
NvmePath: &pb.NvmePath{
Name: np0.Name,
Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TCP,
Traddr: addr[0].String(),
ControllerNameRef: rr0.Name,
Name: np0.Name,
Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TCP,
Traddr: addr[0].String(),

Check warning on line 188 in storage/backend.go

View check run for this annotation

Codecov / codecov/patch

storage/backend.go#L186-L188

Added lines #L186 - L188 were not covered by tests
Fabrics: &pb.FabricsPath{
Adrfam: pb.NvmeAddressFamily_NVME_ADRFAM_IPV4,
Trsvcid: int64(port),
Expand All @@ -198,7 +197,7 @@
return err
}
log.Printf("Updated Nvme path: %v", np3)
np4, err := c5.ListNvmePaths(ctx, &pb.ListNvmePathsRequest{Parent: "todo"})
np4, err := c5.ListNvmePaths(ctx, &pb.ListNvmePathsRequest{Parent: rr0.Name})

Check warning on line 200 in storage/backend.go

View check run for this annotation

Codecov / codecov/patch

storage/backend.go#L200

Added line #L200 was not covered by tests
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions storage/goopicsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@
log.Printf("Connected: %v", response)

pathResponse, err := client.CreateNvmePath(ctx, &pb.CreateNvmePathRequest{
Parent: response.Name,

Check warning on line 68 in storage/goopicsi.go

View check run for this annotation

Codecov / codecov/patch

storage/goopicsi.go#L68

Added line #L68 was not covered by tests
NvmePathId: nvmeControllerToPathResourceID(id),
NvmePath: &pb.NvmePath{
ControllerNameRef: response.Name,
Traddr: trAddr,
Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TCP,
Traddr: trAddr,
Trtype: pb.NvmeTransportType_NVME_TRANSPORT_TCP,

Check warning on line 72 in storage/goopicsi.go

View check run for this annotation

Codecov / codecov/patch

storage/goopicsi.go#L71-L72

Added lines #L71 - L72 were not covered by tests
Fabrics: &pb.FabricsPath{
Subnqn: subnqn,
Trsvcid: trSvcID,
Expand Down Expand Up @@ -107,7 +107,7 @@
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()

response, err := client.ListNvmeRemoteControllers(ctx, &pb.ListNvmeRemoteControllersRequest{Parent: "todo"})
response, err := client.ListNvmeRemoteControllers(ctx, &pb.ListNvmeRemoteControllersRequest{})
if err != nil {
log.Printf("could not list the connections to Remote Nvme controller: %v", err)
return []NvmeConnection{}, err
Expand Down
15 changes: 15 additions & 0 deletions storage/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,18 @@
"controllers", ctrlrResourceID,
)
}

func resourceIDToRemoteControllerName(resourceID string) string {
return resourcename.Join(
"//storage.opiproject.org/",
"nvmeRemoteControllers", resourceID,
)

Check warning on line 43 in storage/resource.go

View check run for this annotation

Codecov / codecov/patch

storage/resource.go#L39-L43

Added lines #L39 - L43 were not covered by tests
}

func resourceIDToNvmePathName(ctrlrResourceID, pathResourceID string) string {
return resourcename.Join(
"//storage.opiproject.org/",
"nvmeRemoteControllers", ctrlrResourceID,
"nvmePaths", pathResourceID,
)

Check warning on line 51 in storage/resource.go

View check run for this annotation

Codecov / codecov/patch

storage/resource.go#L46-L51

Added lines #L46 - L51 were not covered by tests
}
Loading