diff --git a/pkg/model/awsmodel/autoscalinggroup.go b/pkg/model/awsmodel/autoscalinggroup.go index c424420cf7..d9e6ee82ed 100644 --- a/pkg/model/awsmodel/autoscalinggroup.go +++ b/pkg/model/awsmodel/autoscalinggroup.go @@ -539,7 +539,12 @@ func (b *AutoscalingGroupModelBuilder) buildAutoScalingGroupTask(c *fi.ModelBuil t.MixedOnDemandBase = spec.OnDemandBase t.MixedSpotAllocationStrategy = spec.SpotAllocationStrategy t.MixedSpotInstancePools = spec.SpotInstancePools - t.MixedSpotMaxPrice = ig.Spec.MaxPrice + // In order to unset maxprice, the value needs to be "" + if ig.Spec.MaxPrice == nil { + t.MixedSpotMaxPrice = fi.String("") + } else { + t.MixedSpotMaxPrice = ig.Spec.MaxPrice + } } return t, nil diff --git a/tests/integration/update_cluster/mixed_instances/cloudformation.json b/tests/integration/update_cluster/mixed_instances/cloudformation.json index bd5ca3c48d..0423c8ceb1 100644 --- a/tests/integration/update_cluster/mixed_instances/cloudformation.json +++ b/tests/integration/update_cluster/mixed_instances/cloudformation.json @@ -363,7 +363,8 @@ }, "InstancesDistribution": { "OnDemandPercentageAboveBaseCapacity": 5, - "SpotInstancePools": 3 + "SpotInstancePools": 3, + "SpotMaxPrice": "" } } } diff --git a/tests/integration/update_cluster/mixed_instances/kubernetes.tf b/tests/integration/update_cluster/mixed_instances/kubernetes.tf index 3775f5b1cf..d27ed7dbfc 100644 --- a/tests/integration/update_cluster/mixed_instances/kubernetes.tf +++ b/tests/integration/update_cluster/mixed_instances/kubernetes.tf @@ -296,6 +296,7 @@ resource "aws_autoscaling_group" "nodes-mixedinstances-example-com" { instances_distribution { on_demand_percentage_above_base_capacity = 5 spot_instance_pools = 3 + spot_max_price = "" } launch_template { launch_template_specification { diff --git a/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go b/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go index 8750a1281c..086aee8773 100644 --- a/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go +++ b/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go @@ -218,6 +218,10 @@ func (e *AutoscalingGroup) Find(c *fi.Context) (*AutoscalingGroup, error) { actual.MixedSpotAllocationStrategy = mpd.SpotAllocationStrategy actual.MixedSpotInstancePools = mpd.SpotInstancePools actual.MixedSpotMaxPrice = mpd.SpotMaxPrice + // MixedSpotMaxPrice must be set to "" in order to unset. + if mpd.SpotMaxPrice == nil { + actual.MixedSpotMaxPrice = fi.String("") + } } if g.MixedInstancesPolicy.LaunchTemplate != nil {