mirror of https://github.com/kubernetes/kops.git
Paginate DescribeNetworkInterfaces calls
This should help with VPCs containing large numbers of ENIs Signed-off-by: Peter Rifel <pgrifel@gmail.com>
This commit is contained in:
parent
0086ad9a85
commit
7ec30b4a98
|
|
@ -72,18 +72,19 @@ func DescribeENIs(cloud fi.Cloud, clusterName string) (map[string]*ec2.NetworkIn
|
|||
request := &ec2.DescribeNetworkInterfacesInput{
|
||||
Filters: filters,
|
||||
}
|
||||
response, err := c.EC2().DescribeNetworkInterfaces(request)
|
||||
err := c.EC2().DescribeNetworkInterfacesPages(request, func(dnio *ec2.DescribeNetworkInterfacesOutput, b bool) bool {
|
||||
for _, eni := range dnio.NetworkInterfaces {
|
||||
// Skip ENIs that are attached
|
||||
if eni.Attachment != nil {
|
||||
continue
|
||||
}
|
||||
enis[aws.StringValue(eni.NetworkInterfaceId)] = eni
|
||||
}
|
||||
return true
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error listing ENIs: %v", err)
|
||||
}
|
||||
|
||||
for _, eni := range response.NetworkInterfaces {
|
||||
// Skip ENIs that are attached
|
||||
if eni.Attachment != nil {
|
||||
continue
|
||||
}
|
||||
enis[aws.StringValue(eni.NetworkInterfaceId)] = eni
|
||||
}
|
||||
}
|
||||
|
||||
return enis, nil
|
||||
|
|
|
|||
Loading…
Reference in New Issue