From b1f264cefa780c7a46467e228cecd17bcb10b570 Mon Sep 17 00:00:00 2001 From: justinsb Date: Thu, 31 Aug 2023 11:40:56 -0400 Subject: [PATCH] Fix warmpool to expose dependencies for dependency analysis We should populate the AutoscalingGroup field, so that it can be used by dependency analysis. --- pkg/model/awsmodel/autoscalinggroup.go | 7 +++--- upup/pkg/fi/cloudup/awstasks/warmpool.go | 27 +++++++++++++----------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/pkg/model/awsmodel/autoscalinggroup.go b/pkg/model/awsmodel/autoscalinggroup.go index 86ccb7ebe9e42..604d3644489e8 100644 --- a/pkg/model/awsmodel/autoscalinggroup.go +++ b/pkg/model/awsmodel/autoscalinggroup.go @@ -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 diff --git a/upup/pkg/fi/cloudup/awstasks/warmpool.go b/upup/pkg/fi/cloudup/awstasks/warmpool.go index 84397ae18f163..521eb5e9e234c 100644 --- a/upup/pkg/fi/cloudup/awstasks/warmpool.go +++ b/upup/pkg/fi/cloudup/awstasks/warmpool.go @@ -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 @@ -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" { @@ -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 } @@ -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), } @@ -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), })