Skip to content

Commit 9d60945

Browse files
authored
[manila-csi-plugin] Add NodeGetVolumeStats (kubernetes#1737)
NodeGetVolumeStats is now forwarded to the partner plugin if it supports GET_VOLUME_STATS Node Service capability.
1 parent 20af745 commit 9d60945

4 files changed

Lines changed: 18 additions & 1 deletion

File tree

pkg/csi/manila/csiclient/client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ func (c *NodeSvcClient) GetCapabilities(ctx context.Context) (*csi.NodeGetCapabi
3737
return c.cl.NodeGetCapabilities(ctx, &csi.NodeGetCapabilitiesRequest{})
3838
}
3939

40+
func (c *NodeSvcClient) GetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) {
41+
return c.cl.NodeGetVolumeStats(ctx, req)
42+
}
43+
4044
func (c *NodeSvcClient) StageVolume(ctx context.Context, req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error) {
4145
return c.cl.NodeStageVolume(ctx, req)
4246
}

pkg/csi/manila/csiclient/interface.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525

2626
type Node interface {
2727
GetCapabilities(ctx context.Context) (*csi.NodeGetCapabilitiesResponse, error)
28+
GetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error)
2829

2930
StageVolume(ctx context.Context, req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error)
3031
UnstageVolume(ctx context.Context, req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error)

pkg/csi/manila/nodeserver.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,13 @@ func (ns *nodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetC
337337
}
338338

339339
func (ns *nodeServer) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) {
340-
return nil, status.Error(codes.Unimplemented, "")
340+
csiConn, err := ns.d.csiClientBuilder.NewConnectionWithContext(ctx, ns.d.fwdEndpoint)
341+
if err != nil {
342+
return nil, status.Error(codes.Unavailable, fmtGrpcConnError(ns.d.fwdEndpoint, err))
343+
}
344+
defer csiConn.Close()
345+
346+
return ns.d.csiClientBuilder.NewNodeServiceClient(csiConn).GetVolumeStats(ctx, req)
341347
}
342348

343349
func (ns *nodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error) {

tests/sanity/manila/fakecsiclient.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222

2323
"github.com/container-storage-interface/spec/lib/go/csi"
2424
"google.golang.org/grpc"
25+
"google.golang.org/grpc/codes"
26+
"google.golang.org/grpc/status"
2527
"k8s.io/cloud-provider-openstack/pkg/csi/manila/csiclient"
2628
)
2729

@@ -62,6 +64,10 @@ func (c fakeNodeSvcClient) GetCapabilities(context.Context) (*csi.NodeGetCapabil
6264
}, nil
6365
}
6466

67+
func (c fakeNodeSvcClient) GetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) {
68+
return nil, status.Error(codes.Unimplemented, "")
69+
}
70+
6571
func (c fakeNodeSvcClient) StageVolume(context.Context, *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error) {
6672
return &csi.NodeStageVolumeResponse{}, nil
6773
}

0 commit comments

Comments
 (0)