From b493d5b8be91fb6f3d0f119c1da07dcde95832c4 Mon Sep 17 00:00:00 2001 From: Artsiom Koltun Date: Tue, 12 Dec 2023 12:51:14 +0100 Subject: [PATCH 1/2] fix(storage/backend): adjust nvme to parent member Signed-off-by: Artsiom Koltun --- storage/backend.go | 21 ++++++++++----------- storage/goopicsi.go | 8 ++++---- storage/resource.go | 15 +++++++++++++++ 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/storage/backend.go b/storage/backend.go index cf77bbe..4299dea 100644 --- a/storage/backend.go +++ b/storage/backend.go @@ -77,7 +77,7 @@ func executeNvmeRemoteController(ctx context.Context, c4 pb.NvmeRemoteController } newResourceID = parsed.String() } - fullname := resourceIDToVolumeName(newResourceID) + fullname := resourceIDToRemoteControllerName(newResourceID) if rr0.Name != fullname { return fmt.Errorf("server filled value '%s' is not matching user requested '%s'", rr0.Name, fullname) } @@ -88,7 +88,7 @@ func executeNvmeRemoteController(ctx context.Context, c4 pb.NvmeRemoteController return err } log.Printf("Reset Nvme: %v", rr2) - rr3, err := c4.ListNvmeRemoteControllers(ctx, &pb.ListNvmeRemoteControllersRequest{Parent: "todo"}) + rr3, err := c4.ListNvmeRemoteControllers(ctx, &pb.ListNvmeRemoteControllersRequest{}) if err != nil { return err } @@ -150,11 +150,11 @@ func executeNvmePath(ctx context.Context, c5 pb.NvmeRemoteControllerServiceClien for _, resourceID := range []string{"opi-nvme8-path", ""} { np0, err := c5.CreateNvmePath(ctx, &pb.CreateNvmePathRequest{ + Parent: rr0.Name, 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(), Fabrics: &pb.FabricsPath{ Adrfam: pb.NvmeAddressFamily_NVME_ADRFAM_IPV4, Trsvcid: int64(port), @@ -175,7 +175,7 @@ func executeNvmePath(ctx context.Context, c5 pb.NvmeRemoteControllerServiceClien } newResourceID = parsed.String() } - fullname := resourceIDToVolumeName(newResourceID) + fullname := resourceIDToNvmePathName(ctrlrResourceID, newResourceID) if np0.Name != fullname { return fmt.Errorf("server filled value '%s' is not matching user requested '%s'", np0.Name, fullname) } @@ -183,10 +183,9 @@ func executeNvmePath(ctx context.Context, c5 pb.NvmeRemoteControllerServiceClien 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(), Fabrics: &pb.FabricsPath{ Adrfam: pb.NvmeAddressFamily_NVME_ADRFAM_IPV4, Trsvcid: int64(port), @@ -198,7 +197,7 @@ func executeNvmePath(ctx context.Context, c5 pb.NvmeRemoteControllerServiceClien 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}) if err != nil { return err } diff --git a/storage/goopicsi.go b/storage/goopicsi.go index 49d9b5d..e4b42bf 100644 --- a/storage/goopicsi.go +++ b/storage/goopicsi.go @@ -65,11 +65,11 @@ func NvmeControllerConnect(id string, trAddr string, subnqn string, trSvcID int6 log.Printf("Connected: %v", response) pathResponse, err := client.CreateNvmePath(ctx, &pb.CreateNvmePathRequest{ + Parent: response.Name, 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, Fabrics: &pb.FabricsPath{ Subnqn: subnqn, Trsvcid: trSvcID, @@ -107,7 +107,7 @@ func NvmeControllerList() ([]NvmeConnection, error) { 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 diff --git a/storage/resource.go b/storage/resource.go index e22a2c3..c7d6a67 100644 --- a/storage/resource.go +++ b/storage/resource.go @@ -35,3 +35,18 @@ func resourceIDToControllerName(subsysResourceID, ctrlrResourceID string) string "controllers", ctrlrResourceID, ) } + +func resourceIDToRemoteControllerName(resourceID string) string { + return resourcename.Join( + "//storage.opiproject.org/", + "nvmeRemoteControllers", resourceID, + ) +} + +func resourceIDToNvmePathName(ctrlrResourceID, pathResourceID string) string { + return resourcename.Join( + "//storage.opiproject.org/", + "nvmeRemoteControllers", ctrlrResourceID, + "nvmePaths", pathResourceID, + ) +} From 9f776b3a833a3f7667ba23f68fe59bb6f490ed06 Mon Sep 17 00:00:00 2001 From: Artsiom Koltun Date: Thu, 18 Jan 2024 08:26:33 +0100 Subject: [PATCH 2/2] chore(deps): update opi-api to aee3998dd0c Signed-off-by: Artsiom Koltun --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 311143c..599e978 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index dab05a2..da62447 100644 --- a/go.sum +++ b/go.sum @@ -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=