Skip to content

Commit 5ce3f25

Browse files
committed
reassign error returned from validateStoragePools so InvalidArgument error code is recorded instead of internal error code
1 parent 586f6c8 commit 5ce3f25

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/gce-pd-csi-driver/controller.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,9 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
326326

327327
err = validateStoragePools(req, params, gceCS.CloudProvider.GetDefaultProject())
328328
if err != nil {
329-
return nil, status.Errorf(codes.InvalidArgument, "CreateVolume failed to validate storage pools: %v", err)
329+
// Reassign error so that all errors are reported as InvalidArgument to RecordOperationErrorMetrics.
330+
err = status.Errorf(codes.InvalidArgument, "CreateVolume failed to validate storage pools: %v", err)
331+
return nil, err
330332
}
331333

332334
// Verify that the regional availability class is only used on regional disks.
@@ -351,6 +353,7 @@ func (gceCS *GCEControllerServer) CreateVolume(ctx context.Context, req *csi.Cre
351353
if err != nil {
352354
return nil, status.Errorf(codes.InvalidArgument, "CreateVolume failed to pick zones for disk: %v", err.Error())
353355
}
356+
//
354357
if len(zones) != 1 {
355358
return nil, status.Errorf(codes.Internal, "Failed to pick exactly 1 zone for zonal disk, got %v instead", len(zones))
356359
}

0 commit comments

Comments
 (0)