Skip to content

Commit

Permalink
fix: ModifyVolume interface parameter check
Browse files Browse the repository at this point in the history
  • Loading branch information
andyzhangx committed Dec 16, 2024
1 parent 759455b commit 5863016
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions pkg/azuredisk/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
klog.Errorf("invalid create volume req: %v", req)
return nil, err
}
params := req.GetParameters()
diskParams, err := azureutils.ParseDiskParameters(params)
diskParams, err := azureutils.ParseDiskParameters(req.GetParameters())
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "Failed parsing disk parameters: %v", err)
}
if _, err = azureutils.ParseDiskParameters(req.GetMutableParameters()); err != nil {
return nil, status.Errorf(codes.InvalidArgument, "Failed parsing disk mutable parameters: %v", err)
}

name := req.GetName()
if len(name) == 0 {
return nil, status.Error(codes.InvalidArgument, "CreateVolume Name must be provided")
Expand Down Expand Up @@ -400,7 +403,7 @@ func (d *Driver) ControllerModifyVolume(ctx context.Context, req *csi.Controller

diskName, err := azureutils.GetDiskName(diskURI)
if err != nil {
return nil, status.Errorf(codes.Internal, "%v", err)
return nil, status.Errorf(codes.NotFound, "%v", err)
}

if _, err := d.checkDiskExists(ctx, diskURI); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/azuredisk/controllerserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,15 +666,15 @@ func TestControllerModifyVolume(t *testing.T) {
VolumeId: "123",
},
expectedResp: nil,
expectedErrCode: codes.Internal,
expectedErrCode: codes.NotFound,
},
{
desc: "fail with wrong disk name",
req: &csi.ControllerModifyVolumeRequest{
VolumeId: "/subscriptions/123",
},
expectedResp: nil,
expectedErrCode: codes.Internal,
expectedErrCode: codes.NotFound,
},
{
desc: "fail with wrong sku name",
Expand Down

0 comments on commit 5863016

Please sign in to comment.