Skip to content

Commit

Permalink
add volume stats metrics update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyXiangLi committed Jan 6, 2021
1 parent f346abf commit b69f5cd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions pkg/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,17 +356,19 @@ func (d *nodeService) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVo
return nil, status.Error(codes.InvalidArgument, "NodeGetVolumeStats volume path was empty")
}

exists, err := d.mounter.ExistsPath(req.VolumePath)
_, err := os.Stat(req.VolumePath)
if err != nil {
return nil, status.Errorf(codes.Internal, "unknown error when stat on %s: %v", req.VolumePath, err)
}
if !exists {
return nil, status.Errorf(codes.NotFound, "path %s does not exist", req.VolumePath)
if os.IsNotExist(err) {
return nil, status.Errorf(codes.NotFound, "path %s does not exist", req.VolumePath)
}
return nil, status.Errorf(codes.Internal, "failed to stat file %s: %v", req.VolumePath, err)
}

isBlock, err := d.statter.IsBlockDevice(req.VolumePath)

//isBlock, err := hostutil.NewHostUtil().PathIsDevice()
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to determine whether %s is block device: %v", req.VolumePath, err)
return nil, status.Errorf(codes.NotFound, "failed to determine whether %s is block device: %v", req.VolumePath, err)
}
if isBlock {
bcap, err := d.getBlockSizeBytes(req.VolumePath)
Expand Down
2 changes: 1 addition & 1 deletion pkg/driver/sanity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestSanity(t *testing.T) {
}
defer os.RemoveAll(dir)

targetPath := filepath.Join(dir, "target")
targetPath := filepath.Join(dir, "mount")
stagingPath := filepath.Join(dir, "staging")
endpoint := "unix://" + filepath.Join(dir, "csi.sock")

Expand Down

0 comments on commit b69f5cd

Please sign in to comment.