Skip to content

Commit

Permalink
Merge pull request #2741 from k8s-infra-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…2739-to-release-1.31

[release-1.31] fix: ModifyVolume interface parameter check
  • Loading branch information
andyzhangx authored Dec 16, 2024
2 parents b782bc2 + a6ccc45 commit 6574592
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 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
2 changes: 1 addition & 1 deletion test/sanity/run-tests-all-clouds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function install_csi_sanity_bin {
mkdir -p $GOPATH/src/github.com/kubernetes-csi
pushd $GOPATH/src/github.com/kubernetes-csi
export GO111MODULE=off
git clone https://github.com/kubernetes-csi/csi-test.git -b v5.2.0
git clone https://github.com/kubernetes-csi/csi-test.git -b v5.3.1
pushd csi-test/cmd/csi-sanity
make install
popd
Expand Down

0 comments on commit 6574592

Please sign in to comment.