Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated cherry pick of #15848: Fix warmpool to expose dependencies for dependency analysis #15863

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading