mirror of https://github.com/kubernetes/kops.git
Request AWS ASGs in batches
Signed-off-by: Kierran McPherson <kierran.mcpherson@xero.com>
This commit is contained in:
parent
8aa61bc983
commit
0be767a90a
|
|
@ -491,8 +491,10 @@ func FindAutoscalingGroups(c AWSCloud, tags map[string]string) ([]*autoscaling.G
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(asgNames) != 0 {
|
if len(asgNames) != 0 {
|
||||||
|
for i := 0; i < len(asgNames); i += 50 {
|
||||||
|
batch := asgNames[i:minInt(i+50, len(asgNames))]
|
||||||
request := &autoscaling.DescribeAutoScalingGroupsInput{
|
request := &autoscaling.DescribeAutoScalingGroupsInput{
|
||||||
AutoScalingGroupNames: asgNames,
|
AutoScalingGroupNames: batch,
|
||||||
}
|
}
|
||||||
err := c.Autoscaling().DescribeAutoScalingGroupsPages(request, func(p *autoscaling.DescribeAutoScalingGroupsOutput, lastPage bool) bool {
|
err := c.Autoscaling().DescribeAutoScalingGroupsPages(request, func(p *autoscaling.DescribeAutoScalingGroupsOutput, lastPage bool) bool {
|
||||||
for _, asg := range p.AutoScalingGroups {
|
for _, asg := range p.AutoScalingGroups {
|
||||||
|
|
@ -512,12 +514,21 @@ func FindAutoscalingGroups(c AWSCloud, tags map[string]string) ([]*autoscaling.G
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error listing autoscaling groups: %v", err)
|
return nil, fmt.Errorf("error listing autoscaling groups: %v", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return asgs, nil
|
return asgs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the minimum of two ints
|
||||||
|
func minInt(a int, b int) int {
|
||||||
|
if a < b {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
// matchesAsgTags is used to filter an asg by tags
|
// matchesAsgTags is used to filter an asg by tags
|
||||||
func matchesAsgTags(tags map[string]string, actual []*autoscaling.TagDescription) bool {
|
func matchesAsgTags(tags map[string]string, actual []*autoscaling.TagDescription) bool {
|
||||||
for k, v := range tags {
|
for k, v := range tags {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue