Skip to content

Commit

Permalink
Add metrics support
Browse files Browse the repository at this point in the history
Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
  • Loading branch information
humblec committed Apr 4, 2019
1 parent ac9b656 commit 26316b6
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions pkg/cephfs/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,30 @@ func (ns *NodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstag
return &csi.NodeUnstageVolumeResponse{}, nil
}

func (ns *NodeServer) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) {

targetPath := req.GetVolumePath()
volId := req.GetVolumeId()

// Check if the volume is already mounted

isMnt, err := isMountPoint(targetPath)

if err != nil {
klog.Errorf("stat failed: %v", err)
return nil, status.Error(codes.Internal, err.Error())
}

if isMnt {
klog.Infof("cephfs: volume %s is already bind-mounted to %s", volId, targetPath)
return &csi.NodeGetVolumeStatsResponse{}, nil
}

klog.Infof("cephfs: successfully got stats for volume %s to %s", volId, targetPath)

return &csi.NodeGetVolumeStatsResponse{}, nil
}

// NodeGetCapabilities returns the supported capabilities of the node server
func (ns *NodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) {
return &csi.NodeGetCapabilitiesResponse{
Expand All @@ -274,6 +298,13 @@ func (ns *NodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetC
},
},
},
{
Type: &csi.NodeServiceCapability_Rpc{
Rpc: &csi.NodeServiceCapability_RPC{
Type: csi.NodeServiceCapability_RPC_GET_VOLUME_STATS,
},
},
},
},
}, nil
}

0 comments on commit 26316b6

Please sign in to comment.