Skip to content

Commit

Permalink
fix: ModifyVolume interface parameter check
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
andyzhangx authored and k8s-infra-cherrypick-robot committed Dec 16, 2024
1 parent 01cab64 commit a6ccc45
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 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
2 changes: 1 addition & 1 deletion pkg/azuredisk/controllerserver_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func (d *DriverV2) ControllerModifyVolume(ctx context.Context, req *csi.Controll

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

0 comments on commit a6ccc45

Please sign in to comment.