From 7e8ec74292321f7c15f81d443334dd6dc414b4af Mon Sep 17 00:00:00 2001 From: Drew Sirenko <68304519+AndrewSirenko@users.noreply.github.com> Date: Wed, 10 Jan 2024 12:43:55 -0500 Subject: [PATCH] Remove premature CreateVolume error if requested IOPS is below minimum --- pkg/cloud/cloud.go | 15 ++++----------- pkg/cloud/cloud_test.go | 34 ---------------------------------- 2 files changed, 4 insertions(+), 45 deletions(-) diff --git a/pkg/cloud/cloud.go b/pkg/cloud/cloud.go index 178c0e722a..bf4b603aab 100644 --- a/pkg/cloud/cloud.go +++ b/pkg/cloud/cloud.go @@ -511,10 +511,7 @@ func (c *cloud) CreateDisk(ctx context.Context, volumeName string, diskOptions * } else if diskOptions.IOPSPerGB > 0 { requestedIops = int64(diskOptions.IOPSPerGB) * capacityGiB } - iops, err = capIOPS(createType, capacityGiB, requestedIops, minIops, maxIops, maxIopsPerGb, diskOptions.AllowIOPSPerGBIncrease) - if err != nil { - return nil, err - } + iops = capIOPS(createType, capacityGiB, requestedIops, minIops, maxIops, maxIopsPerGb, diskOptions.AllowIOPSPerGBIncrease) } var tags []*ec2.Tag @@ -1505,10 +1502,10 @@ func getVolumeAttachmentsList(volume *ec2.Volume) []string { } // Calculate actual IOPS for a volume and cap it at supported AWS limits. -func capIOPS(volumeType string, requestedCapacityGiB int64, requestedIops int64, minTotalIOPS, maxTotalIOPS, maxIOPSPerGB int64, allowIncrease bool) (int64, error) { +func capIOPS(volumeType string, requestedCapacityGiB int64, requestedIops int64, minTotalIOPS, maxTotalIOPS, maxIOPSPerGB int64, allowIncrease bool) int64 { // If requestedIops is zero the user did not request a specific amount, and the default will be used instead if requestedIops == 0 { - return 0, nil + return 0 } iops := requestedIops @@ -1517,10 +1514,6 @@ func capIOPS(volumeType string, requestedCapacityGiB int64, requestedIops int64, if allowIncrease { iops = minTotalIOPS klog.V(5).InfoS("[Debug] Increased IOPS to the min supported limit", "volumeType", volumeType, "requestedCapacityGiB", requestedCapacityGiB, "limit", iops) - } else if volumeType == VolumeTypeGP3 { - klog.V(5).InfoS("[Debug] Did not increase IOPS", "volumeType", volumeType, "requestedCapacityGiB", requestedCapacityGiB) - } else { - return 0, fmt.Errorf("invalid IOPS: %d is too low, it must be at least %d", iops, minTotalIOPS) } } if iops > maxTotalIOPS { @@ -1532,5 +1525,5 @@ func capIOPS(volumeType string, requestedCapacityGiB int64, requestedIops int64, iops = maxIopsByCapacity klog.V(5).InfoS("[Debug] Capped IOPS for volume", "volumeType", volumeType, "requestedCapacityGiB", requestedCapacityGiB, "maxIOPSPerGB", maxIOPSPerGB, "limit", iops) } - return iops, nil + return iops } diff --git a/pkg/cloud/cloud_test.go b/pkg/cloud/cloud_test.go index 806ee9845e..861372ed3c 100644 --- a/pkg/cloud/cloud_test.go +++ b/pkg/cloud/cloud_test.go @@ -575,23 +575,6 @@ func TestCreateDisk(t *testing.T) { expCreateVolumeInput: nil, expErr: fmt.Errorf("invalid StorageClass parameters; specify either IOPS or IOPSPerGb, not both"), }, - { - name: "fail: io1 with too low iopsPerGB", - volumeName: "vol-test-name", - diskOptions: &DiskOptions{ - CapacityBytes: util.GiBToBytes(4), - Tags: map[string]string{VolumeNameTagKey: "vol-test", AwsEbsDriverTagKey: "true"}, - VolumeType: VolumeTypeIO1, - IOPSPerGB: 1, - }, - expDisk: &Disk{ - VolumeID: "vol-test", - CapacityGiB: 4, - AvailabilityZone: defaultZone, - }, - expCreateVolumeInput: nil, - expErr: fmt.Errorf("invalid IOPS: 4 is too low, it must be at least 100"), - }, { name: "success: small io1 with too high iopsPerGB", volumeName: "vol-test-name", @@ -650,23 +633,6 @@ func TestCreateDisk(t *testing.T) { }, expErr: nil, }, - { - name: "fail: io2 with too low iopsPerGB", - volumeName: "vol-test-name", - diskOptions: &DiskOptions{ - CapacityBytes: util.GiBToBytes(4), - Tags: map[string]string{VolumeNameTagKey: "vol-test", AwsEbsDriverTagKey: "true"}, - VolumeType: VolumeTypeIO2, - IOPSPerGB: 1, - }, - expDisk: &Disk{ - VolumeID: "vol-test", - CapacityGiB: 4, - AvailabilityZone: defaultZone, - }, - expCreateVolumeInput: nil, - expErr: fmt.Errorf("invalid IOPS: 4 is too low, it must be at least 100"), - }, { name: "success: small io2 with too high iopsPerGB", volumeName: "vol-test-name",