Skip to content
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
3 changes: 1 addition & 2 deletions api/v1alpha1/instancegroup_types_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/*

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
17 changes: 10 additions & 7 deletions controllers/providers/aws/constructors.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ limitations under the License.
package aws

import (
"strings"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/eks"
"github.com/keikoproj/instance-manager/controllers/common"
)

func (w *AwsWorker) GetAutoScalingBasicBlockDevice(name, volType, snapshot string, volSize, iops int64, delete, encrypt *bool) *autoscaling.BlockDeviceMapping {
func (w *AwsWorker) GetAutoScalingBasicBlockDevice(name, volType, snapshot string, volSize, iops int64, throughput int64, delete, encrypt *bool) *autoscaling.BlockDeviceMapping {
device := &autoscaling.BlockDeviceMapping{
DeviceName: aws.String(name),
Ebs: &autoscaling.Ebs{
Expand All @@ -40,20 +38,22 @@ func (w *AwsWorker) GetAutoScalingBasicBlockDevice(name, volType, snapshot strin
if encrypt != nil {
device.Ebs.Encrypted = encrypt
}
if iops != 0 && strings.EqualFold(volType, "io1") {
if iops != 0 && common.ContainsEqualFold(AllowedVolumeTypesWithProvisionedIOPS, volType) {
device.Ebs.Iops = aws.Int64(iops)
}
if throughput != 0 && common.ContainsEqualFold(AllowedVolumeTypesWithProvisionedThroughput, volType) {
device.Ebs.Throughput = aws.Int64(throughput)
}
if volSize != 0 {
device.Ebs.VolumeSize = aws.Int64(volSize)
}
if !common.StringEmpty(snapshot) {
device.Ebs.SnapshotId = aws.String(snapshot)
}

return device
}

func (w *AwsWorker) GetLaunchTemplateBlockDeviceRequest(name, volType, snapshot string, volSize, iops int64, delete, encrypt *bool) *ec2.LaunchTemplateBlockDeviceMappingRequest {
func (w *AwsWorker) GetLaunchTemplateBlockDeviceRequest(name, volType, snapshot string, volSize, iops int64, throughput int64, delete, encrypt *bool) *ec2.LaunchTemplateBlockDeviceMappingRequest {
device := &ec2.LaunchTemplateBlockDeviceMappingRequest{
DeviceName: aws.String(name),
Ebs: &ec2.LaunchTemplateEbsBlockDeviceRequest{
Expand All @@ -68,9 +68,12 @@ func (w *AwsWorker) GetLaunchTemplateBlockDeviceRequest(name, volType, snapshot
if encrypt != nil {
device.Ebs.Encrypted = encrypt
}
if iops != 0 && strings.EqualFold(volType, "io1") {
if iops != 0 && common.ContainsEqualFold(AllowedVolumeTypesWithProvisionedIOPS, volType) {
device.Ebs.Iops = aws.Int64(iops)
}
if throughput != 0 && common.ContainsEqualFold(AllowedVolumeTypesWithProvisionedThroughput, volType) {
device.Ebs.Throughput = aws.Int64(throughput)
}
if volSize != 0 {
device.Ebs.VolumeSize = aws.Int64(volSize)
}
Expand Down
8 changes: 4 additions & 4 deletions controllers/provisioners/eks/eks.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ var (
InstanceMgrLifecycleLabel = "instancemgr.keikoproj.io/lifecycle"
InstanceMgrImageLabel = "instancemgr.keikoproj.io/image"

AllowedOsFamilies = []string{OsFamilyWindows, OsFamilyBottleRocket, OsFamilyAmazonLinux2}
DefaultManagedPolicies = []string{"AmazonEKSWorkerNodePolicy", "AmazonEC2ContainerRegistryReadOnly"}
CNIManagedPolicy = "AmazonEKS_CNI_Policy"
SupportedArchitectures = []string{"x86_64", "arm64"}
AllowedOsFamilies = []string{OsFamilyWindows, OsFamilyBottleRocket, OsFamilyAmazonLinux2}
DefaultManagedPolicies = []string{"AmazonEKSWorkerNodePolicy", "AmazonEC2ContainerRegistryReadOnly"}
CNIManagedPolicy = "AmazonEKS_CNI_Policy"
SupportedArchitectures = []string{"x86_64", "arm64"}
)

// New constructs a new instance group provisioner of EKS type
Expand Down
2 changes: 1 addition & 1 deletion controllers/provisioners/eks/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func TestGetBasicUserDataWindows(t *testing.T) {
ctx := MockContext(ig, k, w)

configuration.BootstrapOptions = &v1alpha1.BootstrapOptions{
MaxPods: 4,
MaxPods: 4,
ContainerRuntime: "containerd",
}
configuration.Labels = map[string]string{
Expand Down
2 changes: 1 addition & 1 deletion controllers/provisioners/eks/scaling/launchconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (lc *LaunchConfiguration) placementTenancy(placement *v1alpha1.PlacementSpe
func (lc *LaunchConfiguration) blockDeviceList(volumes []v1alpha1.NodeVolume) []*autoscaling.BlockDeviceMapping {
var devices []*autoscaling.BlockDeviceMapping
for _, v := range volumes {
devices = append(devices, lc.GetAutoScalingBasicBlockDevice(v.Name, v.Type, v.SnapshotID, v.Size, v.Iops, v.DeleteOnTermination, v.Encrypted))
devices = append(devices, lc.GetAutoScalingBasicBlockDevice(v.Name, v.Type, v.SnapshotID, v.Size, v.Iops, v.Throughput, v.DeleteOnTermination, v.Encrypted))
}
return sortConfigDevices(devices)
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/provisioners/eks/scaling/launchtemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ func (lt *LaunchTemplate) RotationNeeded(input *DiscoverConfigurationInput) bool
func (lt *LaunchTemplate) blockDeviceListRequest(volumes []v1alpha1.NodeVolume) []*ec2.LaunchTemplateBlockDeviceMappingRequest {
var devices []*ec2.LaunchTemplateBlockDeviceMappingRequest
for _, v := range volumes {
devices = append(devices, lt.GetLaunchTemplateBlockDeviceRequest(v.Name, v.Type, v.SnapshotID, v.Size, v.Iops, v.DeleteOnTermination, v.Encrypted))
devices = append(devices, lt.GetLaunchTemplateBlockDeviceRequest(v.Name, v.Type, v.SnapshotID, v.Size, v.Iops, v.Throughput, v.DeleteOnTermination, v.Encrypted))
}

return devices
Expand Down
13 changes: 7 additions & 6 deletions controllers/provisioners/eks/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func TestLaunchConfigurationDrifted(t *testing.T) {
SecurityGroups: aws.StringSlice([]string{"sg-1", "sg-2"}),
KeyName: aws.String("somekey"),
UserData: aws.String("userdata"),
BlockDeviceMappings: []*autoscaling.BlockDeviceMapping{w.GetAutoScalingBasicBlockDevice("/dev/xvda", "gp2", "", 40, 100, nil, nil)},
BlockDeviceMappings: []*autoscaling.BlockDeviceMapping{w.GetAutoScalingBasicBlockDevice("/dev/xvda", "gp2", "", 40, 100, 200, nil, nil)},
}

existingConfig := &scaling.CreateConfigurationInput{
Expand All @@ -422,10 +422,11 @@ func TestLaunchConfigurationDrifted(t *testing.T) {
UserData: "userdata",
Volumes: []v1alpha1.NodeVolume{
{
Name: "/dev/xvda",
Type: "gp2",
Size: 40,
Iops: 100,
Name: "/dev/xvda",
Type: "gp2",
Size: 40,
Iops: 100,
Throughput: 200,
},
},
}
Expand All @@ -448,7 +449,7 @@ func TestLaunchConfigurationDrifted(t *testing.T) {
keyDrift.KeyName = aws.String("some-key")
usrDrift.UserData = aws.String("some-userdata")
devDrift.BlockDeviceMappings = []*autoscaling.BlockDeviceMapping{
w.GetAutoScalingBasicBlockDevice("some-device", "some-type", "", 32, 0, nil, nil),
w.GetAutoScalingBasicBlockDevice("some-device", "some-type", "", 32, 0, 0, nil, nil),
}

tests := []struct {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.17

require (
github.com/Masterminds/semver v1.5.0
github.com/aws/aws-sdk-go v1.38.24
github.com/aws/aws-sdk-go v1.38.71
github.com/cucumber/godog v0.8.1
github.com/evanphx/json-patch v4.11.0+incompatible
github.com/ghodss/yaml v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmV
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
github.com/aws/aws-sdk-go v1.35.7/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k=
github.com/aws/aws-sdk-go v1.38.24 h1:zbKHDxFepE77ihVMZ+wZ62Ci646zkorN8rB5s4fj4kU=
github.com/aws/aws-sdk-go v1.38.24/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go v1.38.71 h1:aWhtgoOiDhBCfaAj9XbxzcyvjEAKovbtv7d5mCVBZXw=
github.com/aws/aws-sdk-go v1.38.71/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
Expand Down