Fix unsetting ASG max price

This commit is contained in:
Ole Markus With 2022-06-22 12:26:01 +02:00
parent 9a3e86ca31
commit 2e46fdee1b
4 changed files with 13 additions and 2 deletions

View File

@ -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

View File

@ -363,7 +363,8 @@
},
"InstancesDistribution": {
"OnDemandPercentageAboveBaseCapacity": 5,
"SpotInstancePools": 3
"SpotInstancePools": 3,
"SpotMaxPrice": ""
}
}
}

View File

@ -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 {

View File

@ -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 {