Skip to content

Commit 417cb3f

Browse files
authored
Merge pull request #16931 from spotinst/spotinst/feature/add_aggressiveScaleDown
Spotinst: add aggressive scale down feature
2 parents 763d391 + e9f0fc0 commit 417cb3f

File tree

39 files changed

+3939
-4816
lines changed

39 files changed

+3939
-4816
lines changed

docs/getting_started/spot-ocean.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,13 @@ metadata:
204204
```
205205

206206

207-
| Label | Description | Default |
208-
|-----------------------------------------------------------------|----------------------------------------------------------------------------------------|---|
209-
| `spotinst.io/strategy-cluster-spread-nodes-by` | Specify how Ocean will spread the nodes across markets by this value [vcpu,count]. | `count` |
207+
208+
| Label | Description | Default |
209+
|---|----------------------------------------------------------------------------------------|---|
210+
| `spotinst.io/strategy-cluster-spread-nodes-by` | Specify how Ocean will spread the nodes across markets by this value [vcpu,count]. | `count` |
210211
| `spotinst.io/strategy-cluster-orientation-availability-vs-cost` | Specify approach [cost,balanced,cheapest] that Ocean takes while launching nodes. | `balanced` |
211-
| `spotinst.io/resource-tag-specification-volumes` | Specify if Volume resources will be tagged with Virtual Node Group tags or Ocean tags. | `false` |
212+
| `spotinst.io/resource-tag-specification-volumes` | Specify if Volume resources will be tagged with Virtual Node Group tags or Ocean tags. | `false` |
213+
| `spotinst.io/autoscaler-aggressive-scale-down` | Specify if nodes to be promptly scaled down without any waiting period. | `false` |
212214

213215
## Documentation
214216

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ require (
5858
github.com/spf13/cobra v1.8.1
5959
github.com/spf13/pflag v1.0.5
6060
github.com/spf13/viper v1.19.0
61-
github.com/spotinst/spotinst-sdk-go v1.171.0
61+
github.com/spotinst/spotinst-sdk-go v1.372.0
6262
github.com/stretchr/testify v1.9.0
6363
github.com/weaveworks/mesh v0.0.0-20191105120815-58dbcc3e8e63
6464
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
627627
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
628628
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
629629
github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg=
630-
github.com/spotinst/spotinst-sdk-go v1.171.0 h1:ZihMPEjkpIkSpawWLJt9RtCRY4mOQMGlfrkVmA03000=
631-
github.com/spotinst/spotinst-sdk-go v1.171.0/go.mod h1:Ku9c4p+kRWnQqmXkzGcTMHLcQKgLHrQZISxeKY7mPqE=
630+
github.com/spotinst/spotinst-sdk-go v1.372.0 h1:B4/+HK3D2Fe0821DOmw5RO4Lrzo2gi7oa6QWWjr5/7A=
631+
github.com/spotinst/spotinst-sdk-go v1.372.0/go.mod h1:Tn4/eb0SFY6IXmxz71CClujvbD/PuT+EO6Ta8v6AML4=
632632
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
633633
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
634634
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=

pkg/model/awsmodel/spotinst.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ const (
143143
// SpotClusterLabelResourceTagSpecificationVolumes
144144
// Specify if Volume resources will be tagged with Virtual Node Group tags or Ocean tags.
145145
SpotClusterLabelResourceTagSpecificationVolumes = "spotinst.io/resource-tag-specification-volumes"
146+
147+
// SpotClusterLabelAutoScalerAggressiveScaleDown
148+
// configure the aggressive scale down feature, the default is false. cluster.autoScaler.down.aggressiveScaleDown.isEnabled
149+
SpotClusterLabelAutoScalerAggressiveScaleDown = "spotinst.io/autoscaler-aggressive-scale-down"
146150
)
147151

148152
// SpotInstanceGroupModelBuilder configures SpotInstanceGroup objects
@@ -406,6 +410,11 @@ func (b *SpotInstanceGroupModelBuilder) buildOcean(c *fi.CloudupModelBuilderCont
406410
if err != nil {
407411
return err
408412
}
413+
case SpotClusterLabelAutoScalerAggressiveScaleDown:
414+
ocean.AutoScalerAggressiveScaleDown, err = parseBool(v)
415+
if err != nil {
416+
return err
417+
}
409418
}
410419
}
411420

upup/pkg/fi/cloudup/spotinsttasks/ocean.go

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ type Ocean struct {
6767
SpreadNodesBy *string
6868
AvailabilityVsCost *string
6969
ResourceTagSpecificationVolumes *bool
70+
AutoScalerAggressiveScaleDown *bool
7071
}
7172

7273
var (
@@ -324,9 +325,14 @@ func (o *Ocean) Find(c *fi.CloudupContext) (*Ocean, error) {
324325

325326
// Scale down.
326327
if down := ocean.AutoScaler.Down; down != nil {
327-
actual.AutoScalerOpts.Down = &AutoScalerDownOpts{
328-
MaxPercentage: down.MaxScaleDownPercentage,
329-
EvaluationPeriods: down.EvaluationPeriods,
328+
if down.MaxScaleDownPercentage != nil || down.EvaluationPeriods != nil {
329+
actual.AutoScalerOpts.Down = &AutoScalerDownOpts{
330+
MaxPercentage: down.MaxScaleDownPercentage,
331+
EvaluationPeriods: down.EvaluationPeriods,
332+
}
333+
}
334+
if down.AggressiveScaleDown != nil {
335+
actual.AutoScalerAggressiveScaleDown = down.AggressiveScaleDown.IsEnabled
330336
}
331337
}
332338

@@ -585,6 +591,16 @@ func (_ *Ocean) create(cloud awsup.AWSCloud, a, e, changes *Ocean) error {
585591
MaxMemoryGiB: limits.MaxMemory,
586592
}
587593
}
594+
// create AutoScalerAggressiveScaleDown
595+
{
596+
if e.AutoScalerAggressiveScaleDown != nil {
597+
aggressiveScaleDown := new(aws.AggressiveScaleDown)
598+
if down := autoScaler.Down; down == nil {
599+
autoScaler.Down = new(aws.AutoScalerDown)
600+
}
601+
autoScaler.Down.SetAggressiveScaleDown(aggressiveScaleDown.SetIsEnabled(fi.PtrTo(*e.AutoScalerAggressiveScaleDown)))
602+
}
603+
}
588604

589605
ocean.SetAutoScaler(autoScaler)
590606
}
@@ -1084,6 +1100,15 @@ func (_ *Ocean) update(cloud awsup.AWSCloud, a, e, changes *Ocean) error {
10841100
} else if a.AutoScalerOpts.ResourceLimits != nil {
10851101
autoScaler.SetResourceLimits(nil)
10861102
}
1103+
// AutoScaler aggressive scale down
1104+
if changes.AutoScalerAggressiveScaleDown != nil {
1105+
aggressiveScaleDown := new(aws.AggressiveScaleDown)
1106+
if down := autoScaler.Down; down == nil {
1107+
autoScaler.Down = new(aws.AutoScalerDown)
1108+
}
1109+
autoScaler.Down.SetAggressiveScaleDown(aggressiveScaleDown.SetIsEnabled(fi.PtrTo(*changes.AutoScalerAggressiveScaleDown)))
1110+
changes.AutoScalerAggressiveScaleDown = nil
1111+
}
10871112

10881113
ocean.SetAutoScaler(autoScaler)
10891114
changed = true

vendor/github.com/spotinst/spotinst-sdk-go/service/elastigroup/elastigroup.go

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)