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

Allow throughput with defaulted GP3 volume type #1584

Merged
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
2 changes: 1 addition & 1 deletion pkg/cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 22 additions & 3 deletions pkg/cloud/cloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down