Skip to content

Commit

Permalink
Allow throughput with defaulted GP3 volume type
Browse files Browse the repository at this point in the history
Signed-off-by: Connor Catlett <[email protected]>
  • Loading branch information
ConnorJC3 committed Apr 21, 2023
1 parent dd719c1 commit 88db58c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
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

0 comments on commit 88db58c

Please sign in to comment.