Skip to content

Commit

Permalink
Fix warmpool to expose dependencies for dependency analysis
Browse files Browse the repository at this point in the history
We should populate the AutoscalingGroup field, so that it can be used
by dependency analysis.
  • Loading branch information
justinsb authored and johngmyers committed Sep 4, 2023
1 parent db8b0f3 commit b1f264c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
7 changes: 4 additions & 3 deletions pkg/model/awsmodel/autoscalinggroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ func (b *AutoscalingGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) e

enabled := fi.PtrTo(warmPool.IsEnabled())
warmPoolTask := &awstasks.WarmPool{
Name: &name,
Lifecycle: b.Lifecycle,
Enabled: enabled,
Name: &name,
Lifecycle: b.Lifecycle,
Enabled: enabled,
AutoscalingGroup: b.LinkToAutoscalingGroup(ig),
}
if warmPool.IsEnabled() {
warmPoolTask.MinSize = warmPool.MinSize
Expand Down
27 changes: 15 additions & 12 deletions upup/pkg/fi/cloudup/awstasks/warmpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ import (
// WarmPool provdes the definition for an ASG warm pool in aws.
// +kops:fitask
type WarmPool struct {
// Name is the name of the ASG.
// Name is the name of the task.
Name *string

// Lifecycle is the resource lifecycle.
Lifecycle fi.Lifecycle

Expand All @@ -47,7 +48,7 @@ func (e *WarmPool) Find(c *fi.CloudupContext) (*WarmPool, error) {
cloud := c.T.Cloud.(awsup.AWSCloud)
svc := cloud.Autoscaling()
warmPool, err := svc.DescribeWarmPool(&autoscaling.DescribeWarmPoolInput{
AutoScalingGroupName: e.Name,
AutoScalingGroupName: e.AutoscalingGroup.Name,
})
if err != nil {
if awsup.AWSErrorCode(err) == "ValidationError" {
Expand All @@ -57,18 +58,20 @@ func (e *WarmPool) Find(c *fi.CloudupContext) (*WarmPool, error) {
}
if warmPool.WarmPoolConfiguration == nil {
return &WarmPool{
Name: e.Name,
Lifecycle: e.Lifecycle,
Enabled: fi.PtrTo(false),
Name: e.Name,
Lifecycle: e.Lifecycle,
Enabled: fi.PtrTo(false),
AutoscalingGroup: &AutoscalingGroup{Name: e.AutoscalingGroup.Name},
}, nil
}

actual := &WarmPool{
Name: e.Name,
Lifecycle: e.Lifecycle,
Enabled: fi.PtrTo(true),
MaxSize: warmPool.WarmPoolConfiguration.MaxGroupPreparedCapacity,
MinSize: fi.ValueOf(warmPool.WarmPoolConfiguration.MinSize),
Name: e.Name,
Lifecycle: e.Lifecycle,
Enabled: fi.PtrTo(true),
AutoscalingGroup: &AutoscalingGroup{Name: e.AutoscalingGroup.Name},
MaxSize: warmPool.WarmPoolConfiguration.MaxGroupPreparedCapacity,
MinSize: fi.ValueOf(warmPool.WarmPoolConfiguration.MinSize),
}
return actual, nil
}
Expand All @@ -91,7 +94,7 @@ func (*WarmPool) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *WarmPool) error
maxSize = fi.PtrTo(int64(-1))
}
request := &autoscaling.PutWarmPoolInput{
AutoScalingGroupName: e.Name,
AutoScalingGroupName: e.AutoscalingGroup.Name,
MaxGroupPreparedCapacity: maxSize,
MinSize: fi.PtrTo(minSize),
}
Expand All @@ -105,7 +108,7 @@ func (*WarmPool) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *WarmPool) error
}
} else if a != nil {
_, err := svc.DeleteWarmPool(&autoscaling.DeleteWarmPoolInput{
AutoScalingGroupName: e.Name,
AutoScalingGroupName: e.AutoscalingGroup.Name,
// We don't need to do any cleanup so, the faster the better
ForceDelete: fi.PtrTo(true),
})
Expand Down

0 comments on commit b1f264c

Please sign in to comment.