From 436dbe8435daa65d25367f435feae3c9d5b7ce39 Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Tue, 11 May 2021 13:24:33 -0700 Subject: [PATCH] Refactor LaunchTemplate.RootVolumeIops --- pkg/model/awsmodel/autoscalinggroup.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/model/awsmodel/autoscalinggroup.go b/pkg/model/awsmodel/autoscalinggroup.go index a4b930bad0..d2a5485f13 100644 --- a/pkg/model/awsmodel/autoscalinggroup.go +++ b/pkg/model/awsmodel/autoscalinggroup.go @@ -160,9 +160,9 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde InstanceInterruptionBehavior: ig.Spec.InstanceInterruptionBehavior, InstanceMonitoring: ig.Spec.DetailedInstanceMonitoring, InstanceType: fi.String(strings.Split(ig.Spec.MachineType, ",")[0]), + RootVolumeIops: fi.Int64(int64(fi.Int32Value(ig.Spec.RootVolumeIops))), RootVolumeOptimization: lc.RootVolumeOptimization, RootVolumeSize: lc.RootVolumeSize, - RootVolumeIops: lc.RootVolumeIops, RootVolumeType: fi.String(rootVolumeType), RootVolumeEncryption: lc.RootVolumeEncryption, SSHKey: lc.SSHKey, @@ -242,20 +242,18 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde if rootVolumeType == ec2.VolumeTypeIo1 || rootVolumeType == ec2.VolumeTypeIo2 { if fi.Int32Value(ig.Spec.RootVolumeIops) < 100 { lt.RootVolumeIops = fi.Int64(int64(DefaultVolumeIonIops)) - } else { - lt.RootVolumeIops = fi.Int64(int64(fi.Int32Value(ig.Spec.RootVolumeIops))) } } else if rootVolumeType == ec2.VolumeTypeGp3 { if fi.Int32Value(ig.Spec.RootVolumeIops) < 3000 { lt.RootVolumeIops = fi.Int64(int64(DefaultVolumeGp3Iops)) - } else { - lt.RootVolumeIops = fi.Int64(int64(fi.Int32Value(ig.Spec.RootVolumeIops))) } if fi.Int32Value(ig.Spec.RootVolumeThroughput) < 125 { lt.RootVolumeThroughput = fi.Int64(int64(DefaultVolumeGp3Throughput)) } else { lt.RootVolumeThroughput = fi.Int64(int64(fi.Int32Value(ig.Spec.RootVolumeThroughput))) } + } else { + lt.RootVolumeIops = nil } // When using a MixedInstances ASG, AWS requires the SpotPrice be defined on the ASG