Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove premature CreateVolume error if requested IOPS is below minimum #1883

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions pkg/cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
torredil marked this conversation as resolved.
Show resolved Hide resolved
// 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
}
torredil marked this conversation as resolved.
Show resolved Hide resolved

iops := requestedIops
Expand All @@ -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 {
Expand All @@ -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
}
34 changes: 0 additions & 34 deletions pkg/cloud/cloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
},
torredil marked this conversation as resolved.
Show resolved Hide resolved
{
name: "success: small io1 with too high iopsPerGB",
volumeName: "vol-test-name",
Expand Down Expand Up @@ -650,23 +633,6 @@ func TestCreateDisk(t *testing.T) {
},
expErr: nil,
},
{
name: "fail: io2 with too low iopsPerGB",
torredil marked this conversation as resolved.
Show resolved Hide resolved
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",
Expand Down