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 d553224
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 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
23 changes: 21 additions & 2 deletions pkg/cloud/cloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func TestCreateDisk(t *testing.T) {
},
expCreateVolumeInput: &ec2.CreateVolumeInput{
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 d553224

Please sign in to comment.