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())
|
enabled := fi.PtrTo(warmPool.IsEnabled())
|
||||||
warmPoolTask := &awstasks.WarmPool{
|
warmPoolTask := &awstasks.WarmPool{
|
||||||
Name: &name,
|
Name: &name,
|
||||||
Lifecycle: b.Lifecycle,
|
Lifecycle: b.Lifecycle,
|
||||||
Enabled: enabled,
|
Enabled: enabled,
|
||||||
|
AutoscalingGroup: b.LinkToAutoscalingGroup(ig),
|
||||||
}
|
}
|
||||||
if warmPool.IsEnabled() {
|
if warmPool.IsEnabled() {
|
||||||
warmPoolTask.MinSize = warmPool.MinSize
|
warmPoolTask.MinSize = warmPool.MinSize
|
||||||
|
|
|
@ -28,8 +28,9 @@ import (
|
||||||
// WarmPool provdes the definition for an ASG warm pool in aws.
|
// WarmPool provdes the definition for an ASG warm pool in aws.
|
||||||
// +kops:fitask
|
// +kops:fitask
|
||||||
type WarmPool struct {
|
type WarmPool struct {
|
||||||
// Name is the name of the ASG.
|
// Name is the name of the task.
|
||||||
Name *string
|
Name *string
|
||||||
|
|
||||||
// Lifecycle is the resource lifecycle.
|
// Lifecycle is the resource lifecycle.
|
||||||
Lifecycle fi.Lifecycle
|
Lifecycle fi.Lifecycle
|
||||||
|
|
||||||
|
@ -47,7 +48,7 @@ func (e *WarmPool) Find(c *fi.CloudupContext) (*WarmPool, error) {
|
||||||
cloud := c.T.Cloud.(awsup.AWSCloud)
|
cloud := c.T.Cloud.(awsup.AWSCloud)
|
||||||
svc := cloud.Autoscaling()
|
svc := cloud.Autoscaling()
|
||||||
warmPool, err := svc.DescribeWarmPool(&autoscaling.DescribeWarmPoolInput{
|
warmPool, err := svc.DescribeWarmPool(&autoscaling.DescribeWarmPoolInput{
|
||||||
AutoScalingGroupName: e.Name,
|
AutoScalingGroupName: e.AutoscalingGroup.Name,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if awsup.AWSErrorCode(err) == "ValidationError" {
|
if awsup.AWSErrorCode(err) == "ValidationError" {
|
||||||
|
@ -57,18 +58,20 @@ func (e *WarmPool) Find(c *fi.CloudupContext) (*WarmPool, error) {
|
||||||
}
|
}
|
||||||
if warmPool.WarmPoolConfiguration == nil {
|
if warmPool.WarmPoolConfiguration == nil {
|
||||||
return &WarmPool{
|
return &WarmPool{
|
||||||
Name: e.Name,
|
Name: e.Name,
|
||||||
Lifecycle: e.Lifecycle,
|
Lifecycle: e.Lifecycle,
|
||||||
Enabled: fi.PtrTo(false),
|
Enabled: fi.PtrTo(false),
|
||||||
|
AutoscalingGroup: &AutoscalingGroup{Name: e.AutoscalingGroup.Name},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
actual := &WarmPool{
|
actual := &WarmPool{
|
||||||
Name: e.Name,
|
Name: e.Name,
|
||||||
Lifecycle: e.Lifecycle,
|
Lifecycle: e.Lifecycle,
|
||||||
Enabled: fi.PtrTo(true),
|
Enabled: fi.PtrTo(true),
|
||||||
MaxSize: warmPool.WarmPoolConfiguration.MaxGroupPreparedCapacity,
|
AutoscalingGroup: &AutoscalingGroup{Name: e.AutoscalingGroup.Name},
|
||||||
MinSize: fi.ValueOf(warmPool.WarmPoolConfiguration.MinSize),
|
MaxSize: warmPool.WarmPoolConfiguration.MaxGroupPreparedCapacity,
|
||||||
|
MinSize: fi.ValueOf(warmPool.WarmPoolConfiguration.MinSize),
|
||||||
}
|
}
|
||||||
return actual, nil
|
return actual, nil
|
||||||
}
|
}
|
||||||
|
@ -91,7 +94,7 @@ func (*WarmPool) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *WarmPool) error
|
||||||
maxSize = fi.PtrTo(int64(-1))
|
maxSize = fi.PtrTo(int64(-1))
|
||||||
}
|
}
|
||||||
request := &autoscaling.PutWarmPoolInput{
|
request := &autoscaling.PutWarmPoolInput{
|
||||||
AutoScalingGroupName: e.Name,
|
AutoScalingGroupName: e.AutoscalingGroup.Name,
|
||||||
MaxGroupPreparedCapacity: maxSize,
|
MaxGroupPreparedCapacity: maxSize,
|
||||||
MinSize: fi.PtrTo(minSize),
|
MinSize: fi.PtrTo(minSize),
|
||||||
}
|
}
|
||||||
|
@ -105,7 +108,7 @@ func (*WarmPool) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *WarmPool) error
|
||||||
}
|
}
|
||||||
} else if a != nil {
|
} else if a != nil {
|
||||||
_, err := svc.DeleteWarmPool(&autoscaling.DeleteWarmPoolInput{
|
_, 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
|
// We don't need to do any cleanup so, the faster the better
|
||||||
ForceDelete: fi.PtrTo(true),
|
ForceDelete: fi.PtrTo(true),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue