Skip to content

Commit

Permalink
fix(deps): handle errors in NodeGetVolumeStats() for sanity
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyberezansky committed Sep 25, 2024
1 parent 5c873f1 commit e2a4396
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/wekafs/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi

ok, err := volume.Exists(ctx)
if err != nil {
return ExpandVolumeError(ctx, codes.Internal, err.Error())
return ExpandVolumeError(ctx, codes.NotFound, err.Error())
}
if !ok {
return ExpandVolumeError(ctx, codes.Internal, "Volume does not exist")
Expand Down
13 changes: 10 additions & 3 deletions pkg/wekafs/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,16 @@ func (ns *NodeServer) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVo
volumePath := req.GetVolumePath()

// Validate request fields
if volumeID == "" || volumePath == "" {
return nil, status.Error(codes.InvalidArgument, "Volume ID and path must be provided")
if volumeID == "" {
return nil, status.Error(codes.InvalidArgument, "Volume ID must be provided")
}
if volumePath == "" {
return nil, status.Error(codes.NotFound, "Volume path must be provided")
}
if req.GetStagingTargetPath() != "" {
if !PathExists(req.GetStagingTargetPath()) {
return nil, status.Error(codes.NotFound, "Staging area path not found")
}
}

// Check if the volume path exists
Expand Down Expand Up @@ -185,7 +193,6 @@ func NewNodeServer(nodeId string, maxVolumesPerNode int64, api *ApiStore, mounte
csi.NodeServiceCapability_RPC_SINGLE_NODE_MULTI_WRITER,
csi.NodeServiceCapability_RPC_GET_VOLUME_STATS,
csi.NodeServiceCapability_RPC_VOLUME_CONDITION,
//csi.NodeServiceCapability_RPC_EXPAND_VOLUME,
},
),
nodeID: nodeId,
Expand Down

0 comments on commit e2a4396

Please sign in to comment.