Skip to content

Commit 7ebd7f2

Browse files
authored
Fix: Not honoring gp3 volume iops and throughput values (#380)
* Fix: Not honoring gp3 volume iops and throughput values Signed-off-by: Venkata Gunapati <[email protected]> * clean up Signed-off-by: Venkata Gunapati <[email protected]> --------- Signed-off-by: Venkata Gunapati <[email protected]>
1 parent fc56922 commit 7ebd7f2

File tree

9 files changed

+28
-25
lines changed

9 files changed

+28
-25
lines changed

api/v1alpha1/instancegroup_types_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/*
2-
32
Licensed under the Apache License, Version 2.0 (the "License");
43
you may not use this file except in compliance with the License.
54
You may obtain a copy of the License at
65
7-
http://www.apache.org/licenses/LICENSE-2.0
6+
http://www.apache.org/licenses/LICENSE-2.0
87
98
Unless required by applicable law or agreed to in writing, software
109
distributed under the License is distributed on an "AS IS" BASIS,

controllers/providers/aws/constructors.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@ limitations under the License.
1616
package aws
1717

1818
import (
19-
"strings"
20-
2119
"github.com/aws/aws-sdk-go/aws"
2220
"github.com/aws/aws-sdk-go/service/autoscaling"
2321
"github.com/aws/aws-sdk-go/service/ec2"
2422
"github.com/aws/aws-sdk-go/service/eks"
2523
"github.com/keikoproj/instance-manager/controllers/common"
2624
)
2725

28-
func (w *AwsWorker) GetAutoScalingBasicBlockDevice(name, volType, snapshot string, volSize, iops int64, delete, encrypt *bool) *autoscaling.BlockDeviceMapping {
26+
func (w *AwsWorker) GetAutoScalingBasicBlockDevice(name, volType, snapshot string, volSize, iops int64, throughput int64, delete, encrypt *bool) *autoscaling.BlockDeviceMapping {
2927
device := &autoscaling.BlockDeviceMapping{
3028
DeviceName: aws.String(name),
3129
Ebs: &autoscaling.Ebs{
@@ -40,20 +38,22 @@ func (w *AwsWorker) GetAutoScalingBasicBlockDevice(name, volType, snapshot strin
4038
if encrypt != nil {
4139
device.Ebs.Encrypted = encrypt
4240
}
43-
if iops != 0 && strings.EqualFold(volType, "io1") {
41+
if iops != 0 && common.ContainsEqualFold(AllowedVolumeTypesWithProvisionedIOPS, volType) {
4442
device.Ebs.Iops = aws.Int64(iops)
4543
}
44+
if throughput != 0 && common.ContainsEqualFold(AllowedVolumeTypesWithProvisionedThroughput, volType) {
45+
device.Ebs.Throughput = aws.Int64(throughput)
46+
}
4647
if volSize != 0 {
4748
device.Ebs.VolumeSize = aws.Int64(volSize)
4849
}
4950
if !common.StringEmpty(snapshot) {
5051
device.Ebs.SnapshotId = aws.String(snapshot)
5152
}
52-
5353
return device
5454
}
5555

56-
func (w *AwsWorker) GetLaunchTemplateBlockDeviceRequest(name, volType, snapshot string, volSize, iops int64, delete, encrypt *bool) *ec2.LaunchTemplateBlockDeviceMappingRequest {
56+
func (w *AwsWorker) GetLaunchTemplateBlockDeviceRequest(name, volType, snapshot string, volSize, iops int64, throughput int64, delete, encrypt *bool) *ec2.LaunchTemplateBlockDeviceMappingRequest {
5757
device := &ec2.LaunchTemplateBlockDeviceMappingRequest{
5858
DeviceName: aws.String(name),
5959
Ebs: &ec2.LaunchTemplateEbsBlockDeviceRequest{
@@ -68,9 +68,12 @@ func (w *AwsWorker) GetLaunchTemplateBlockDeviceRequest(name, volType, snapshot
6868
if encrypt != nil {
6969
device.Ebs.Encrypted = encrypt
7070
}
71-
if iops != 0 && strings.EqualFold(volType, "io1") {
71+
if iops != 0 && common.ContainsEqualFold(AllowedVolumeTypesWithProvisionedIOPS, volType) {
7272
device.Ebs.Iops = aws.Int64(iops)
7373
}
74+
if throughput != 0 && common.ContainsEqualFold(AllowedVolumeTypesWithProvisionedThroughput, volType) {
75+
device.Ebs.Throughput = aws.Int64(throughput)
76+
}
7477
if volSize != 0 {
7578
device.Ebs.VolumeSize = aws.Int64(volSize)
7679
}

controllers/provisioners/eks/eks.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ var (
5454
InstanceMgrLifecycleLabel = "instancemgr.keikoproj.io/lifecycle"
5555
InstanceMgrImageLabel = "instancemgr.keikoproj.io/image"
5656

57-
AllowedOsFamilies = []string{OsFamilyWindows, OsFamilyBottleRocket, OsFamilyAmazonLinux2}
58-
DefaultManagedPolicies = []string{"AmazonEKSWorkerNodePolicy", "AmazonEC2ContainerRegistryReadOnly"}
59-
CNIManagedPolicy = "AmazonEKS_CNI_Policy"
60-
SupportedArchitectures = []string{"x86_64", "arm64"}
57+
AllowedOsFamilies = []string{OsFamilyWindows, OsFamilyBottleRocket, OsFamilyAmazonLinux2}
58+
DefaultManagedPolicies = []string{"AmazonEKSWorkerNodePolicy", "AmazonEC2ContainerRegistryReadOnly"}
59+
CNIManagedPolicy = "AmazonEKS_CNI_Policy"
60+
SupportedArchitectures = []string{"x86_64", "arm64"}
6161
)
6262

6363
// New constructs a new instance group provisioner of EKS type

controllers/provisioners/eks/helpers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func TestGetBasicUserDataWindows(t *testing.T) {
189189
ctx := MockContext(ig, k, w)
190190

191191
configuration.BootstrapOptions = &v1alpha1.BootstrapOptions{
192-
MaxPods: 4,
192+
MaxPods: 4,
193193
ContainerRuntime: "containerd",
194194
}
195195
configuration.Labels = map[string]string{

controllers/provisioners/eks/scaling/launchconfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ func (lc *LaunchConfiguration) placementTenancy(placement *v1alpha1.PlacementSpe
288288
func (lc *LaunchConfiguration) blockDeviceList(volumes []v1alpha1.NodeVolume) []*autoscaling.BlockDeviceMapping {
289289
var devices []*autoscaling.BlockDeviceMapping
290290
for _, v := range volumes {
291-
devices = append(devices, lc.GetAutoScalingBasicBlockDevice(v.Name, v.Type, v.SnapshotID, v.Size, v.Iops, v.DeleteOnTermination, v.Encrypted))
291+
devices = append(devices, lc.GetAutoScalingBasicBlockDevice(v.Name, v.Type, v.SnapshotID, v.Size, v.Iops, v.Throughput, v.DeleteOnTermination, v.Encrypted))
292292
}
293293
return sortConfigDevices(devices)
294294
}

controllers/provisioners/eks/scaling/launchtemplate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ func (lt *LaunchTemplate) RotationNeeded(input *DiscoverConfigurationInput) bool
334334
func (lt *LaunchTemplate) blockDeviceListRequest(volumes []v1alpha1.NodeVolume) []*ec2.LaunchTemplateBlockDeviceMappingRequest {
335335
var devices []*ec2.LaunchTemplateBlockDeviceMappingRequest
336336
for _, v := range volumes {
337-
devices = append(devices, lt.GetLaunchTemplateBlockDeviceRequest(v.Name, v.Type, v.SnapshotID, v.Size, v.Iops, v.DeleteOnTermination, v.Encrypted))
337+
devices = append(devices, lt.GetLaunchTemplateBlockDeviceRequest(v.Name, v.Type, v.SnapshotID, v.Size, v.Iops, v.Throughput, v.DeleteOnTermination, v.Encrypted))
338338
}
339339

340340
return devices

controllers/provisioners/eks/update_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ func TestLaunchConfigurationDrifted(t *testing.T) {
408408
SecurityGroups: aws.StringSlice([]string{"sg-1", "sg-2"}),
409409
KeyName: aws.String("somekey"),
410410
UserData: aws.String("userdata"),
411-
BlockDeviceMappings: []*autoscaling.BlockDeviceMapping{w.GetAutoScalingBasicBlockDevice("/dev/xvda", "gp2", "", 40, 100, nil, nil)},
411+
BlockDeviceMappings: []*autoscaling.BlockDeviceMapping{w.GetAutoScalingBasicBlockDevice("/dev/xvda", "gp2", "", 40, 100, 200, nil, nil)},
412412
}
413413

414414
existingConfig := &scaling.CreateConfigurationInput{
@@ -422,10 +422,11 @@ func TestLaunchConfigurationDrifted(t *testing.T) {
422422
UserData: "userdata",
423423
Volumes: []v1alpha1.NodeVolume{
424424
{
425-
Name: "/dev/xvda",
426-
Type: "gp2",
427-
Size: 40,
428-
Iops: 100,
425+
Name: "/dev/xvda",
426+
Type: "gp2",
427+
Size: 40,
428+
Iops: 100,
429+
Throughput: 200,
429430
},
430431
},
431432
}
@@ -448,7 +449,7 @@ func TestLaunchConfigurationDrifted(t *testing.T) {
448449
keyDrift.KeyName = aws.String("some-key")
449450
usrDrift.UserData = aws.String("some-userdata")
450451
devDrift.BlockDeviceMappings = []*autoscaling.BlockDeviceMapping{
451-
w.GetAutoScalingBasicBlockDevice("some-device", "some-type", "", 32, 0, nil, nil),
452+
w.GetAutoScalingBasicBlockDevice("some-device", "some-type", "", 32, 0, 0, nil, nil),
452453
}
453454

454455
tests := []struct {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.17
44

55
require (
66
github.com/Masterminds/semver v1.5.0
7-
github.com/aws/aws-sdk-go v1.38.24
7+
github.com/aws/aws-sdk-go v1.38.71
88
github.com/cucumber/godog v0.8.1
99
github.com/evanphx/json-patch v4.11.0+incompatible
1010
github.com/ghodss/yaml v1.0.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmV
5151
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
5252
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
5353
github.com/aws/aws-sdk-go v1.35.7/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k=
54-
github.com/aws/aws-sdk-go v1.38.24 h1:zbKHDxFepE77ihVMZ+wZ62Ci646zkorN8rB5s4fj4kU=
55-
github.com/aws/aws-sdk-go v1.38.24/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
54+
github.com/aws/aws-sdk-go v1.38.71 h1:aWhtgoOiDhBCfaAj9XbxzcyvjEAKovbtv7d5mCVBZXw=
55+
github.com/aws/aws-sdk-go v1.38.71/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
5656
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
5757
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
5858
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=

0 commit comments

Comments
 (0)