Skip to content

Commit

Permalink
refactor(storage): latest API changes
Browse files Browse the repository at this point in the history
ObjectStats -> StatsObject
VolumeId -> VolumeNameRef
remove pc.ObjectKey

Signed-off-by: Boris Glimcher <[email protected]>
  • Loading branch information
glimchb committed Aug 2, 2023
1 parent 9fda07a commit 599a089
Show file tree
Hide file tree
Showing 28 changed files with 284 additions and 294 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ docker run --network=host --rm -it namely/grpc-cli call --json_input --json_outp
docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 CreateNvmeNamespace "{nvme_namespace : {spec : {subsystem_name_ref : '//storage.opiproject.org/volumes/subsystem2', volume_name_ref : 'Malloc0', 'host_nsid' : '10', uuid:{value : '1b4e28ba-2fa1-11d2-883f-b9a761bde3fb'}, nguid: '1b4e28ba-2fa1-11d2-883f-b9a761bde3fb', eui64: 1967554867335598546 } }, nvme_namespace_id: 'namespace1'}"
docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 ListNvmeNamespaces "{parent : '//storage.opiproject.org/volumes/subsystem2'}"
docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 GetNvmeNamespace "{name : '//storage.opiproject.org/volumes/namespace1'}"
docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 NvmeNamespaceStats "{name : '//storage.opiproject.org/volumes/namespace1'}"
docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 StatsNvmeNamespace "{name : '//storage.opiproject.org/volumes/namespace1'}"
docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 CreateNvmeRemoteController "{nvme_remote_controller : {multipath: 'NVME_MULTIPATH_MULTIPATH'}, nvme_remote_controller_id: 'nvmetcp12'}"
docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 ListNvmeRemoteControllers "{parent : 'todo'}"
docker run --network=host --rm -it namely/grpc-cli call --json_input --json_output 10.10.10.10:50051 GetNvmeRemoteController "{name: '//storage.opiproject.org/volumes/nvmetcp12'}"
Expand Down Expand Up @@ -140,19 +140,19 @@ service FrontendNvmeService {
rpc UpdateNvmeSubsystem(opi_api.storage.v1.UpdateNvmeSubsystemRequest) returns (opi_api.storage.v1.NvmeSubsystem) {}
rpc ListNvmeSubsystem(opi_api.storage.v1.ListNvmeSubsystemRequest) returns (opi_api.storage.v1.ListNvmeSubsystemResponse) {}
rpc GetNvmeSubsystem(opi_api.storage.v1.GetNvmeSubsystemRequest) returns (opi_api.storage.v1.NvmeSubsystem) {}
rpc NvmeSubsystemStats(opi_api.storage.v1.NvmeSubsystemStatsRequest) returns (opi_api.storage.v1.NvmeSubsystemStatsResponse) {}
rpc StatsNvmeSubsystem(opi_api.storage.v1.StatsNvmeSubsystemRequest) returns (opi_api.storage.v1.StatsNvmeSubsystemResponse) {}
rpc CreateNvmeController(opi_api.storage.v1.CreateNvmeControllerRequest) returns (opi_api.storage.v1.NvmeController) {}
rpc DeleteNvmeController(opi_api.storage.v1.DeleteNvmeControllerRequest) returns (google.protobuf.Empty) {}
rpc UpdateNvmeController(opi_api.storage.v1.UpdateNvmeControllerRequest) returns (opi_api.storage.v1.NvmeController) {}
rpc ListNvmeController(opi_api.storage.v1.ListNvmeControllerRequest) returns (opi_api.storage.v1.ListNvmeControllerResponse) {}
rpc GetNvmeController(opi_api.storage.v1.GetNvmeControllerRequest) returns (opi_api.storage.v1.NvmeController) {}
rpc NvmeControllerStats(opi_api.storage.v1.NvmeControllerStatsRequest) returns (opi_api.storage.v1.NvmeControllerStatsResponse) {}
rpc StatsNvmeController(opi_api.storage.v1.StatsNvmeControllerRequest) returns (opi_api.storage.v1.StatsNvmeControllerResponse) {}
rpc CreateNvmeNamespace(opi_api.storage.v1.CreateNvmeNamespaceRequest) returns (opi_api.storage.v1.NvmeNamespace) {}
rpc DeleteNvmeNamespace(opi_api.storage.v1.DeleteNvmeNamespaceRequest) returns (google.protobuf.Empty) {}
rpc UpdateNvmeNamespace(opi_api.storage.v1.UpdateNvmeNamespaceRequest) returns (opi_api.storage.v1.NvmeNamespace) {}
rpc ListNvmeNamespace(opi_api.storage.v1.ListNvmeNamespaceRequest) returns (opi_api.storage.v1.ListNvmeNamespaceResponse) {}
rpc GetNvmeNamespace(opi_api.storage.v1.GetNvmeNamespaceRequest) returns (opi_api.storage.v1.NvmeNamespace) {}
rpc NvmeNamespaceStats(opi_api.storage.v1.NvmeNamespaceStatsRequest) returns (opi_api.storage.v1.NvmeNamespaceStatsResponse) {}
rpc StatsNvmeNamespace(opi_api.storage.v1.StatsNvmeNamespaceRequest) returns (opi_api.storage.v1.StatsNvmeNamespaceResponse) {}
}
```

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ services:
test: grpcurl -plaintext localhost:50051 list || exit 1

opi-spdk-client:
image: ghcr.io/opiproject/godpu:main@sha256:c35775b11f5bafbdc3a24d5f7ad01de0ea31050592e040a3f55ec2b5911ee972
image: ghcr.io/opiproject/godpu:main@sha256:ec7d7ccf40c02cf13dd9afbd874f7de2d0350b0ae8f61e8e943ac45aa3a75919
networks:
- opi
depends_on:
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/digitalocean/go-qemu v0.0.0-20230711162256-2e3d0186973e
github.com/google/uuid v1.3.0
github.com/opiproject/gospdk v0.0.0-20230724125810-f9b59208a93e
github.com/opiproject/opi-api v0.0.0-20230728150746-cc0946b7cec4
github.com/opiproject/opi-api v0.0.0-20230802143709-76c2f23d70d5
go.einride.tech/aip v0.61.0
google.golang.org/grpc v1.57.0
google.golang.org/protobuf v1.31.0
Expand All @@ -15,10 +15,10 @@ require (
require (
github.com/digitalocean/go-libvirt v0.0.0-20220804181439-8648fbde413e // indirect
github.com/golang/protobuf v1.5.3 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/net v0.13.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
google.golang.org/genproto v0.0.0-20230726155614-23370e0ffb3e // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e // indirect
google.golang.org/genproto v0.0.0-20230731193218-e0aa005b6bdf // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230731193218-e0aa005b6bdf // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230731193218-e0aa005b6bdf // indirect
)
28 changes: 11 additions & 17 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,16 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/opiproject/gospdk v0.0.0-20230721162442-5187c4c6663b h1:MYk4lS7uUpJwT89WJgjqg9RCXywslytpBDmZcWy626I=
github.com/opiproject/gospdk v0.0.0-20230721162442-5187c4c6663b/go.mod h1:RqA5Ix7+x0Is8UckJE+6Ji5kCfk6yujWWaTMoRlZv3w=
github.com/opiproject/gospdk v0.0.0-20230724125810-f9b59208a93e h1:y27NgCS0+ESFLR40iwWm7OM0qi++zTjRDuQt09+iie8=
github.com/opiproject/gospdk v0.0.0-20230724125810-f9b59208a93e/go.mod h1:RqA5Ix7+x0Is8UckJE+6Ji5kCfk6yujWWaTMoRlZv3w=
github.com/opiproject/opi-api v0.0.0-20230728150746-cc0946b7cec4 h1:wOsrhHoOo5h1S7BwcPoQsWPPb0ILV6QNX8Fc53GqQ/o=
github.com/opiproject/opi-api v0.0.0-20230728150746-cc0946b7cec4/go.mod h1:92pv4ulvvPMuxCJ9ND3aYbmBfEMLx0VCjpkiR7ZTqPY=
github.com/opiproject/opi-api v0.0.0-20230802143709-76c2f23d70d5 h1:L0TDC4GEqKUpoiZAqEezI/Cha5sstiXg4ZNqLgYUPn0=
github.com/opiproject/opi-api v0.0.0-20230802143709-76c2f23d70d5/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/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
go.einride.tech/aip v0.60.0 h1:h6bgabZ5BCfAptbGex8jbh3VvPBRLa6xq+pQ1CAjHYw=
go.einride.tech/aip v0.60.0/go.mod h1:SdLbSbgSU60Xkb4TMkmsZEQPHeEWx0ikBoq5QnqZvdg=
go.einride.tech/aip v0.61.0 h1:H7r59BtQDcj8kGNa0Dytw88so1iWrzp6mSOEQgcIJWI=
go.einride.tech/aip v0.61.0/go.mod h1:YVrCQRL7SCB5Mv7i2ZF1R6vkLPh844RQBCLrrLcefaU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand All @@ -33,8 +29,8 @@ golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
golang.org/x/net v0.13.0 h1:Nvo8UFsZ8X3BhAC9699Z1j7XQ3rsZnUUm7jfBEk1ueY=
golang.org/x/net v0.13.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand All @@ -56,14 +52,12 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto v0.0.0-20230726155614-23370e0ffb3e h1:xIXmWJ303kJCuogpj0bHq+dcjcZHU+XFyc1I0Yl9cRg=
google.golang.org/genproto v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:0ggbjUrZYpy1q+ANUS30SEoGZ53cdfwtbuG7Ptgy108=
google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e h1:z3vDksarJxsAKM5dmEGv0GHwE2hKJ096wZra71Vs4sw=
google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e h1:S83+ibolgyZ0bqz7KEsUOPErxcv4VzlszxY+31OfB/E=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM=
google.golang.org/grpc v1.56.2 h1:fVRFRnXvU+x6C4IlHZewvJOVHoOv1TUuQyoRsYnB4bI=
google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s=
google.golang.org/genproto v0.0.0-20230731193218-e0aa005b6bdf h1:v5Cf4E9+6tawYrs/grq1q1hFpGtzlGFzgWHqwt6NFiU=
google.golang.org/genproto v0.0.0-20230731193218-e0aa005b6bdf/go.mod h1:oH/ZOT02u4kWEp7oYBGYFFkCdKS/uYR9Z7+0/xuuFp8=
google.golang.org/genproto/googleapis/api v0.0.0-20230731193218-e0aa005b6bdf h1:xkVZ5FdZJF4U82Q/JS+DcZA83s/GRVL+QrFMlexk9Yo=
google.golang.org/genproto/googleapis/api v0.0.0-20230731193218-e0aa005b6bdf/go.mod h1:5DZzOUPCLYL3mNkQ0ms0F3EuUNZ7py1Bqeq6sxzI7/Q=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230731193218-e0aa005b6bdf h1:guOdSPaeFgN+jEJwTo1dQ71hdBm+yKSCCKuTRkJzcVo=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230731193218-e0aa005b6bdf/go.mod h1:zBEcrKX2ZOcEkHWxBPAIvYUWOKKMIhYcmNiUIu2ji3I=
google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw=
google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
Expand All @@ -73,4 +67,4 @@ google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o=
gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY=
14 changes: 7 additions & 7 deletions pkg/backend/aio.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,23 +288,23 @@ func (s *Server) GetAioVolume(_ context.Context, in *pb.GetAioVolumeRequest) (*p
return &pb.AioVolume{Name: result[0].Name, BlockSize: result[0].BlockSize, BlocksCount: result[0].NumBlocks}, nil
}

// AioVolumeStats gets an Aio volume stats
func (s *Server) AioVolumeStats(_ context.Context, in *pb.AioVolumeStatsRequest) (*pb.AioVolumeStatsResponse, error) {
log.Printf("AioVolumeStats: Received from client: %v", in)
// StatsAioVolume gets an Aio volume stats
func (s *Server) StatsAioVolume(_ context.Context, in *pb.StatsAioVolumeRequest) (*pb.StatsAioVolumeResponse, error) {
log.Printf("StatsAioVolume: Received from client: %v", in)
// check required fields
if err := fieldbehavior.ValidateRequiredFields(in); err != nil {
log.Printf("error: %v", err)
return nil, err
}
// Validate that a resource name conforms to the restrictions outlined in AIP-122.
if err := resourcename.Validate(in.Handle.Value); err != nil {
if err := resourcename.Validate(in.Name); err != nil {
log.Printf("error: %v", err)
return nil, err
}
// fetch object from the database
volume, ok := s.Volumes.AioVolumes[in.Handle.Value]
volume, ok := s.Volumes.AioVolumes[in.Name]
if !ok {
err := status.Errorf(codes.NotFound, "unable to find key %s", in.Handle.Value)
err := status.Errorf(codes.NotFound, "unable to find key %s", in.Name)
log.Printf("error: %v", err)
return nil, err
}
Expand All @@ -325,7 +325,7 @@ func (s *Server) AioVolumeStats(_ context.Context, in *pb.AioVolumeStatsRequest)
log.Print(msg)
return nil, status.Errorf(codes.InvalidArgument, msg)
}
return &pb.AioVolumeStatsResponse{Stats: &pb.VolumeStats{
return &pb.StatsAioVolumeResponse{Stats: &pb.VolumeStats{
ReadBytesCount: int32(result.Bdevs[0].BytesRead),
ReadOpsCount: int32(result.Bdevs[0].NumReadOps),
WriteBytesCount: int32(result.Bdevs[0].BytesWritten),
Expand Down
7 changes: 3 additions & 4 deletions pkg/backend/aio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

pc "github.com/opiproject/opi-api/common/v1/gen/go"
pb "github.com/opiproject/opi-api/storage/v1alpha1/gen/go"
"github.com/opiproject/opi-spdk-bridge/pkg/server"
)
Expand Down Expand Up @@ -617,7 +616,7 @@ func TestBackEnd_GetAioVolume(t *testing.T) {
}
}

func TestBackEnd_AioVolumeStats(t *testing.T) {
func TestBackEnd_StatsAioVolume(t *testing.T) {
tests := map[string]struct {
in string
out *pb.VolumeStats
Expand Down Expand Up @@ -698,8 +697,8 @@ func TestBackEnd_AioVolumeStats(t *testing.T) {

testEnv.opiSpdkServer.Volumes.AioVolumes[testAioVolumeID] = &testAioVolume

request := &pb.AioVolumeStatsRequest{Handle: &pc.ObjectKey{Value: tt.in}}
response, err := testEnv.client.AioVolumeStats(testEnv.ctx, request)
request := &pb.StatsAioVolumeRequest{Name: tt.in}
response, err := testEnv.client.StatsAioVolume(testEnv.ctx, request)

if !proto.Equal(tt.out, response.GetStats()) {
t.Error("response: expected", tt.out, "received", response.GetStats())
Expand Down
14 changes: 7 additions & 7 deletions pkg/backend/null.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,23 +289,23 @@ func (s *Server) GetNullVolume(_ context.Context, in *pb.GetNullVolumeRequest) (
return &pb.NullVolume{Name: result[0].Name, Uuid: &pc.Uuid{Value: result[0].UUID}, BlockSize: result[0].BlockSize, BlocksCount: result[0].NumBlocks}, nil
}

// NullVolumeStats gets a Null volume instance stats
func (s *Server) NullVolumeStats(_ context.Context, in *pb.NullVolumeStatsRequest) (*pb.NullVolumeStatsResponse, error) {
log.Printf("NullVolumeStats: Received from client: %v", in)
// StatsNullVolume gets a Null volume instance stats
func (s *Server) StatsNullVolume(_ context.Context, in *pb.StatsNullVolumeRequest) (*pb.StatsNullVolumeResponse, error) {
log.Printf("StatsNullVolume: Received from client: %v", in)
// check required fields
if err := fieldbehavior.ValidateRequiredFields(in); err != nil {
log.Printf("error: %v", err)
return nil, err
}
// Validate that a resource name conforms to the restrictions outlined in AIP-122.
if err := resourcename.Validate(in.Handle.Value); err != nil {
if err := resourcename.Validate(in.Name); err != nil {
log.Printf("error: %v", err)
return nil, err
}
// fetch object from the database
volume, ok := s.Volumes.NullVolumes[in.Handle.Value]
volume, ok := s.Volumes.NullVolumes[in.Name]
if !ok {
err := status.Errorf(codes.NotFound, "unable to find key %s", in.Handle.Value)
err := status.Errorf(codes.NotFound, "unable to find key %s", in.Name)
log.Printf("error: %v", err)
return nil, err
}
Expand All @@ -326,7 +326,7 @@ func (s *Server) NullVolumeStats(_ context.Context, in *pb.NullVolumeStatsReques
log.Print(msg)
return nil, status.Errorf(codes.InvalidArgument, msg)
}
return &pb.NullVolumeStatsResponse{Stats: &pb.VolumeStats{
return &pb.StatsNullVolumeResponse{Stats: &pb.VolumeStats{
ReadBytesCount: int32(result.Bdevs[0].BytesRead),
ReadOpsCount: int32(result.Bdevs[0].NumReadOps),
WriteBytesCount: int32(result.Bdevs[0].BytesWritten),
Expand Down
6 changes: 3 additions & 3 deletions pkg/backend/null_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ func TestBackEnd_GetNullVolume(t *testing.T) {
}
}

func TestBackEnd_NullVolumeStats(t *testing.T) {
func TestBackEnd_StatsNullVolume(t *testing.T) {
tests := map[string]struct {
in string
out *pb.VolumeStats
Expand Down Expand Up @@ -704,8 +704,8 @@ func TestBackEnd_NullVolumeStats(t *testing.T) {

testEnv.opiSpdkServer.Volumes.NullVolumes[testNullVolumeID] = &testNullVolume

request := &pb.NullVolumeStatsRequest{Handle: &pc.ObjectKey{Value: tt.in}}
response, err := testEnv.client.NullVolumeStats(testEnv.ctx, request)
request := &pb.StatsNullVolumeRequest{Name: tt.in}
response, err := testEnv.client.StatsNullVolume(testEnv.ctx, request)

if !proto.Equal(response.GetStats(), tt.out) {
t.Error("response: expected", tt.out, "received", response.GetStats())
Expand Down
10 changes: 5 additions & 5 deletions pkg/backend/nvme_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func (s *Server) DeleteNvmeRemoteController(_ context.Context, in *pb.DeleteNvme
return &emptypb.Empty{}, nil
}

// NvmeRemoteControllerReset resets an Nvme remote controller
func (s *Server) NvmeRemoteControllerReset(_ context.Context, in *pb.NvmeRemoteControllerResetRequest) (*emptypb.Empty, error) {
// ResetNvmeRemoteController resets an Nvme remote controller
func (s *Server) ResetNvmeRemoteController(_ context.Context, in *pb.ResetNvmeRemoteControllerRequest) (*emptypb.Empty, error) {
log.Printf("Received: %v", in.GetName())
// check required fields
if err := fieldbehavior.ValidateRequiredFields(in); err != nil {
Expand Down Expand Up @@ -169,8 +169,8 @@ func (s *Server) GetNvmeRemoteController(_ context.Context, in *pb.GetNvmeRemote
return response, nil
}

// NvmeRemoteControllerStats gets Nvme remote controller stats
func (s *Server) NvmeRemoteControllerStats(_ context.Context, in *pb.NvmeRemoteControllerStatsRequest) (*pb.NvmeRemoteControllerStatsResponse, error) {
// StatsNvmeRemoteController gets Nvme remote controller stats
func (s *Server) StatsNvmeRemoteController(_ context.Context, in *pb.StatsNvmeRemoteControllerRequest) (*pb.StatsNvmeRemoteControllerResponse, error) {
log.Printf("Received: %v", in.GetName())
// check required fields
if err := fieldbehavior.ValidateRequiredFields(in); err != nil {
Expand All @@ -191,5 +191,5 @@ func (s *Server) NvmeRemoteControllerStats(_ context.Context, in *pb.NvmeRemoteC
}
name := path.Base(volume.Name)
log.Printf("TODO: send name to SPDK and get back stats: %v", name)
return &pb.NvmeRemoteControllerStatsResponse{Stats: &pb.VolumeStats{ReadOpsCount: -1, WriteOpsCount: -1}}, nil
return &pb.StatsNvmeRemoteControllerResponse{Stats: &pb.VolumeStats{ReadOpsCount: -1, WriteOpsCount: -1}}, nil
}
Loading

0 comments on commit 599a089

Please sign in to comment.