Skip to content

Commit 92c5191

Browse files
authored
Merge pull request #2729 from ConnorJC3/fix-throughput
Fix throughput handling
2 parents c8dc351 + 0b9dde4 commit 92c5191

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

pkg/cloud/cloud.go

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -609,14 +609,12 @@ func extractVolumeKey(v *types.Volume, batcher volumeBatcherType) (string, error
609609

610610
func (c *cloud) CreateDisk(ctx context.Context, volumeName string, diskOptions *DiskOptions) (*Disk, error) {
611611
var (
612-
createType string
613-
iops int32
614-
throughput int32
615-
err error
616-
requestedIops int32
617-
size int32
618-
outpostArn string
619-
volumeID string
612+
createType string
613+
iops int32
614+
err error
615+
size int32
616+
outpostArn string
617+
volumeID string
620618
)
621619

622620
isClone := diskOptions.SourceVolumeID != ""
@@ -684,13 +682,13 @@ func (c *cloud) CreateDisk(ctx context.Context, volumeName string, diskOptions *
684682
return nil, fmt.Errorf("invalid AWS VolumeType %q", diskOptions.VolumeType)
685683
}
686684

687-
if iopsLimit.maxIops > 0 {
688-
if diskOptions.IOPS > 0 {
689-
requestedIops = diskOptions.IOPS
690-
} else if diskOptions.IOPSPerGB > 0 {
691-
requestedIops = diskOptions.IOPSPerGB * capacityGiB
692-
}
693-
iops = capIOPS(createType, capacityGiB, requestedIops, iopsLimit, diskOptions.AllowIOPSPerGBIncrease)
685+
if diskOptions.IOPS > 0 {
686+
iops = diskOptions.IOPS
687+
} else if diskOptions.IOPSPerGB > 0 {
688+
iops = diskOptions.IOPSPerGB * capacityGiB
689+
}
690+
if iopsLimit.maxIops > 0 && iops > 0 {
691+
iops = capIOPS(createType, capacityGiB, iops, iopsLimit, diskOptions.AllowIOPSPerGBIncrease)
694692
}
695693

696694
if isClone {
@@ -702,7 +700,7 @@ func (c *cloud) CreateDisk(ctx context.Context, volumeName string, diskOptions *
702700
MultiAttachEnabled: aws.Bool(diskOptions.MultiAttachEnabled),
703701
TagSpecifications: []types.TagSpecification{tagSpec},
704702
}
705-
size, outpostArn, volumeID, err = c.createCloneHelper(ctx, copyRequestInput, iops, throughput)
703+
size, outpostArn, volumeID, err = c.createCloneHelper(ctx, copyRequestInput, iops, diskOptions.Throughput)
706704
} else {
707705
createRequestInput := &ec2.CreateVolumeInput{
708706
ClientToken: aws.String(hex.EncodeToString(clientToken[:])),
@@ -712,7 +710,7 @@ func (c *cloud) CreateDisk(ctx context.Context, volumeName string, diskOptions *
712710
MultiAttachEnabled: aws.Bool(diskOptions.MultiAttachEnabled),
713711
TagSpecifications: []types.TagSpecification{tagSpec},
714712
}
715-
size, outpostArn, volumeID, err = c.createVolumeHelper(ctx, diskOptions, createRequestInput, iops, throughput, zone, zoneID)
713+
size, outpostArn, volumeID, err = c.createVolumeHelper(ctx, diskOptions, createRequestInput, iops, diskOptions.Throughput, zone, zoneID)
716714
}
717715
if err != nil {
718716
switch {

0 commit comments

Comments
 (0)