From a6ccc4591151d391bcbe06a2d1d0287255d529e8 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Mon, 16 Dec 2024 03:56:16 +0000 Subject: [PATCH] fix: ModifyVolume interface parameter check fix --- pkg/azuredisk/controllerserver.go | 9 ++++++--- pkg/azuredisk/controllerserver_test.go | 4 ++-- pkg/azuredisk/controllerserver_v2.go | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/azuredisk/controllerserver.go b/pkg/azuredisk/controllerserver.go index 7dc962716a..f33cd931b8 100644 --- a/pkg/azuredisk/controllerserver.go +++ b/pkg/azuredisk/controllerserver.go @@ -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") @@ -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 { diff --git a/pkg/azuredisk/controllerserver_test.go b/pkg/azuredisk/controllerserver_test.go index 4fa9e647ae..c0f1761f97 100644 --- a/pkg/azuredisk/controllerserver_test.go +++ b/pkg/azuredisk/controllerserver_test.go @@ -666,7 +666,7 @@ func TestControllerModifyVolume(t *testing.T) { VolumeId: "123", }, expectedResp: nil, - expectedErrCode: codes.Internal, + expectedErrCode: codes.NotFound, }, { desc: "fail with wrong disk name", @@ -674,7 +674,7 @@ func TestControllerModifyVolume(t *testing.T) { VolumeId: "/subscriptions/123", }, expectedResp: nil, - expectedErrCode: codes.Internal, + expectedErrCode: codes.NotFound, }, { desc: "fail with wrong sku name", diff --git a/pkg/azuredisk/controllerserver_v2.go b/pkg/azuredisk/controllerserver_v2.go index 78ee23cb39..7d8609d12e 100644 --- a/pkg/azuredisk/controllerserver_v2.go +++ b/pkg/azuredisk/controllerserver_v2.go @@ -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 {