Skip to content

Commit

Permalink
fixup! add check for shared volumes in getVolumeStats
Browse files Browse the repository at this point in the history
Signed-off-by: dahuang <[email protected]>
  • Loading branch information
dahuang-purestorage committed Feb 20, 2024
1 parent b015850 commit b4ed691
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
11 changes: 0 additions & 11 deletions csi/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,17 +363,6 @@ func (s *OsdCsiServer) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetV
return nil, err
}

var attachPathMatch bool
for _, attachPath := range vol.AttachPath {
sharedPath := fmt.Sprintf("%s/%s", api.SharedVolExportPrefix, id)
if attachPath == path || attachPath == sharedPath {
attachPathMatch = true
}
}
if !attachPathMatch {
return nil, status.Errorf(codes.NotFound, "Volume %s not mounted on path %s", id, path)
}

// Define volume usage
total := int64(vol.Spec.Size)
used := int64(vol.Usage)
Expand Down
1 change: 1 addition & 0 deletions csi/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,7 @@ func TestNodeGetVolumeStats(t *testing.T) {
assert.Equal(t, "Volume status is up", resp.VolumeCondition.Message)

// Get VolumeStats - shared volume
// it should return the same stats as the first call
resp, err = c.NodeGetVolumeStats(
context.Background(),
&csi.NodeGetVolumeStatsRequest{VolumeId: id, VolumePath: sharedPath})
Expand Down

0 comments on commit b4ed691

Please sign in to comment.