Skip to content

Comments

aws/ec2: properly paginate DescribeNetworkInterfaces results#6

Open
MitchLewis930 wants to merge 1 commit intopr_046_beforefrom
pr_046_after
Open

aws/ec2: properly paginate DescribeNetworkInterfaces results#6
MitchLewis930 wants to merge 1 commit intopr_046_beforefrom
pr_046_after

Conversation

@MitchLewis930
Copy link

PR_046

Signed-off-by: Anton Ippolitov <anton.ippolitov@datadoghq.com>
@greptile-apps
Copy link

greptile-apps bot commented Jan 30, 2026

Greptile Overview

Greptile Summary

Added explicit MaxResults parameter (set to 1000) to three DescribeNetworkInterfaces API calls to improve pagination efficiency and consistency.

  • Modified describeNetworkInterfaces(), describeNetworkInterfacesByInstance(), and describeNetworkInterfacesFromInstances() in pkg/aws/ec2/ec2.go
  • Introduced ENIMaxResultsPerApiCall constant (value: 1000) in pkg/defaults/defaults.go
  • All three functions already use paginators correctly, ensuring all results are fetched across multiple pages
  • 1000 is the maximum value allowed by AWS EC2 API for DescribeNetworkInterfaces

This change optimizes API calls by requesting the maximum number of results per page instead of relying on AWS default page sizes, reducing the total number of API calls needed for large result sets.

Confidence Score: 5/5

  • This PR is safe to merge with no concerns
  • The changes are minimal, well-scoped, and correct. The constant value of 1000 matches the AWS API maximum, and all modified functions already use proper pagination patterns. This is a pure optimization that reduces API calls without changing behavior.
  • No files require special attention

Important Files Changed

Filename Overview
pkg/aws/ec2/ec2.go Added MaxResults parameter to three DescribeNetworkInterfaces calls for proper pagination control
pkg/defaults/defaults.go Introduced ENIMaxResultsPerApiCall constant set to 1000 (AWS API maximum)

Sequence Diagram

sequenceDiagram
    participant Client as EC2 Client
    participant AWS as AWS EC2 API
    participant Paginator as DescribeNetworkInterfacesPaginator
    
    Note over Client: describeNetworkInterfaces() called
    Client->>Client: Create DescribeNetworkInterfacesInput<br/>with MaxResults=1000
    Client->>Paginator: NewDescribeNetworkInterfacesPaginator(input)
    
    loop while paginator.HasMorePages()
        Client->>Client: limiter.Limit() - rate limiting
        Client->>Paginator: NextPage(ctx)
        Paginator->>AWS: DescribeNetworkInterfaces<br/>(MaxResults: 1000)
        AWS-->>Paginator: NetworkInterfaces (up to 1000)<br/>+ NextToken if more exist
        Paginator-->>Client: Output with NetworkInterfaces
        Client->>Client: Append results to result array
    end
    
    Client-->>Client: Return all NetworkInterfaces
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants