mirror of https://github.com/kubernetes/kops.git
Fix warmpool to expose dependencies for dependency analysis
We should populate the AutoscalingGroup field, so that it can be used by dependency analysis.
This commit is contained in:
parent
62e7d71ae8
commit
f5c2f2bcba
|
@ -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
|
||||
|
|
|
@ -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),
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue