From 88db58c8b3850bb0f482456ebb338054b0038082 Mon Sep 17 00:00:00 2001 From: Connor Catlett Date: Fri, 21 Apr 2023 12:52:58 -0400 Subject: [PATCH] Allow throughput with defaulted GP3 volume type Signed-off-by: Connor Catlett --- pkg/cloud/cloud.go | 2 +- pkg/cloud/cloud_test.go | 25 ++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/pkg/cloud/cloud.go b/pkg/cloud/cloud.go index 9e61c93b5f..0e18ccb64b 100644 --- a/pkg/cloud/cloud.go +++ b/pkg/cloud/cloud.go @@ -393,7 +393,7 @@ func (c *cloud) CreateDisk(ctx context.Context, volumeName string, diskOptions * if iops > 0 { requestInput.Iops = aws.Int64(iops) } - if throughput > 0 && diskOptions.VolumeType == VolumeTypeGP3 { + if throughput > 0 { requestInput.Throughput = aws.Int64(throughput) } snapshotID := diskOptions.SnapshotID diff --git a/pkg/cloud/cloud_test.go b/pkg/cloud/cloud_test.go index 2c2c9a8a03..e98d61536e 100644 --- a/pkg/cloud/cloud_test.go +++ b/pkg/cloud/cloud_test.go @@ -175,7 +175,8 @@ func TestCreateDisk(t *testing.T) { AvailabilityZone: defaultZone, }, expCreateVolumeInput: &ec2.CreateVolumeInput{ - Iops: aws.Int64(3000), + Iops: aws.Int64(3000), + Throughput: aws.Int64(125), }, expErr: nil, }, @@ -551,6 +552,24 @@ func TestCreateDisk(t *testing.T) { }, expErr: fmt.Errorf("could not attach tags to volume: vol-test. CreateTags generic error"), }, + { + name: "success: create default volume with throughput", + volumeName: "vol-test-name", + diskOptions: &DiskOptions{ + CapacityBytes: util.GiBToBytes(1), + Tags: map[string]string{VolumeNameTagKey: "vol-test", AwsEbsDriverTagKey: "true"}, + Throughput: 250, + }, + expCreateVolumeInput: &ec2.CreateVolumeInput{ + Throughput: aws.Int64(250), + }, + expDisk: &Disk{ + VolumeID: "vol-test", + CapacityGiB: 1, + AvailabilityZone: defaultZone, + }, + expErr: nil, + }, } for _, tc := range testCases { @@ -1961,8 +1980,8 @@ func (m *eqCreateVolumeMatcher) Matches(x interface{}) bool { if input == nil { return false } - // Compare only IOPS for now - ret := reflect.DeepEqual(m.expected.Iops, input.Iops) + // TODO: Check all inputs + ret := reflect.DeepEqual(m.expected.Iops, input.Iops) && reflect.DeepEqual(m.expected.Throughput, input.Throughput) return ret }