Skip to content

Commit f4b66bc

Browse files
committed
WIP: discover the warmPool in the ASG task
1 parent 26effbe commit f4b66bc

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

Diff for: pkg/model/awsmodel/autoscalinggroup.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ func (b *AutoscalingGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) e
103103
if warmPool.MaxSize != nil {
104104
warmPoolTask.MaxSize = fi.PtrTo(int32(aws.ToInt64(warmPool.MaxSize)))
105105
}
106-
tsk.WarmPool = warmPoolTask
106+
// tsk.WarmPool = warmPoolTask
107107
} else {
108-
tsk.WarmPool = nil
108+
// tsk.WarmPool = nil
109109
}
110110
c.AddTask(warmPoolTask)
111111

Diff for: upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,12 @@ type AutoscalingGroup struct {
100100
TargetGroups []*TargetGroup
101101
// CapacityRebalance makes ASG proactively replace spot instances when ASG receives a rebalance recommendation
102102
CapacityRebalance *bool
103-
// WarmPool is the WarmPool config for the ASG
104-
WarmPool *WarmPool
103+
104+
// warmPool is the WarmPool config for the ASG
105+
// The WarmPool has a reference to the ASG, so this field would introduce a circular dependency if public.
106+
// We need the warmPool here only for terraform, which configures the warmPool inside the ASG.
107+
// To avoid the circular dependency, we make the field private.
108+
warmPool *WarmPool
105109

106110
deletions []fi.CloudupDeletion
107111
}
@@ -1100,10 +1104,10 @@ func (_ *AutoscalingGroup) RenderTerraform(t *terraform.TerraformTarget, a, e, c
11001104
}
11011105
tf.SuspendedProcesses = processes
11021106

1103-
if e.WarmPool != nil && *e.WarmPool.Enabled {
1107+
if e.warmPool != nil && *e.warmPool.Enabled {
11041108
tf.WarmPool = &terraformWarmPool{
1105-
MinSize: &e.WarmPool.MinSize,
1106-
MaxSize: e.WarmPool.MaxSize,
1109+
MinSize: &e.warmPool.MinSize,
1110+
MaxSize: e.warmPool.MaxSize,
11071111
}
11081112
}
11091113

Diff for: upup/pkg/fi/cloudup/awstasks/autoscalinggroup_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ terraform {
342342
MixedOnDemandBase: fi.PtrTo(int32(4)),
343343
MixedOnDemandAboveBase: fi.PtrTo(int32(30)),
344344
MixedSpotAllocationStrategy: fi.PtrTo("capacity-optimized"),
345-
WarmPool: &WarmPool{
345+
warmPool: &WarmPool{
346346
Enabled: fi.PtrTo(true),
347347
MinSize: 3,
348348
MaxSize: fi.PtrTo(int32(5)),

Diff for: upup/pkg/fi/cloudup/awstasks/warmpool.go

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type WarmPool struct {
4141
// MinSize is the smallest number of nodes in the warm pool.
4242
MinSize int32
4343

44+
// AutoscalingGroup is the AutoscalingGroup on which we configure this warmpool.
4445
AutoscalingGroup *AutoscalingGroup
4546
}
4647

0 commit comments

Comments
 (0)