diff --git a/pkg/awsutils/awsutils.go b/pkg/awsutils/awsutils.go index c013b34df7..6c02a00451 100644 --- a/pkg/awsutils/awsutils.go +++ b/pkg/awsutils/awsutils.go @@ -33,6 +33,7 @@ import ( "github.com/aws/amazon-vpc-cni-k8s/pkg/utils/retry" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/request" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" "k8s.io/apimachinery/pkg/util/sets" @@ -79,6 +80,8 @@ var ( // ErrNoNetworkInterfaces occurs when // DesribeNetworkInterfaces(eniID) returns no network interfaces ErrNoNetworkInterfaces = errors.New("No network interfaces found for ENI") + // Custom user agent + userAgent = request.WithAppendUserAgent("amazon-vpc-cni-k8s") ) var log = logger.Get() @@ -549,7 +552,7 @@ func (cache *EC2InstanceMetadataCache) awsGetFreeDeviceNumber() (int, error) { } start := time.Now() - result, err := cache.ec2SVC.DescribeInstances(input) + result, err := cache.ec2SVC.DescribeInstancesWithContext(context.Background(), input, userAgent) awsAPILatency.WithLabelValues("DescribeInstances", fmt.Sprint(err != nil)).Observe(msSince(start)) if err != nil { awsAPIErrInc("DescribeInstances", err) @@ -615,7 +618,7 @@ func (cache *EC2InstanceMetadataCache) AllocENI(useCustomCfg bool, sg []*string, } start := time.Now() - _, err = cache.ec2SVC.ModifyNetworkInterfaceAttribute(attributeInput) + _, err = cache.ec2SVC.ModifyNetworkInterfaceAttributeWithContext(context.Background(), attributeInput, userAgent) awsAPILatency.WithLabelValues("ModifyNetworkInterfaceAttribute", fmt.Sprint(err != nil)).Observe(msSince(start)) if err != nil { awsAPIErrInc("ModifyNetworkInterfaceAttribute", err) @@ -644,7 +647,7 @@ func (cache *EC2InstanceMetadataCache) attachENI(eniID string) (string, error) { NetworkInterfaceId: aws.String(eniID), } start := time.Now() - attachOutput, err := cache.ec2SVC.AttachNetworkInterface(attachInput) + attachOutput, err := cache.ec2SVC.AttachNetworkInterfaceWithContext(context.Background(), attachInput, userAgent) awsAPILatency.WithLabelValues("AttachNetworkInterface", fmt.Sprint(err != nil)).Observe(msSince(start)) if err != nil { awsAPIErrInc("AttachNetworkInterface", err) @@ -676,7 +679,7 @@ func (cache *EC2InstanceMetadataCache) createENI(useCustomCfg bool, sg []*string } log.Infof("Creating ENI with security groups: %v in subnet: %s", sgs, *input.SubnetId) start := time.Now() - result, err := cache.ec2SVC.CreateNetworkInterface(input) + result, err := cache.ec2SVC.CreateNetworkInterfaceWithContext(context.Background(), input, userAgent) awsAPILatency.WithLabelValues("CreateNetworkInterface", fmt.Sprint(err != nil)).Observe(msSince(start)) if err != nil { awsAPIErrInc("CreateNetworkInterface", err) @@ -729,7 +732,7 @@ func (cache *EC2InstanceMetadataCache) tagENI(eniID string, maxBackoffDelay time _ = retry.RetryNWithBackoff(retry.NewSimpleBackoff(500*time.Millisecond, maxBackoffDelay, 0.3, 2), 5, func() error { start := time.Now() - _, err := cache.ec2SVC.CreateTags(input) + _, err := cache.ec2SVC.CreateTagsWithContext(context.Background(), input, userAgent) awsAPILatency.WithLabelValues("CreateTags", fmt.Sprint(err != nil)).Observe(msSince(start)) if err != nil { awsAPIErrInc("CreateTags", err) @@ -819,7 +822,7 @@ func (cache *EC2InstanceMetadataCache) freeENI(eniName string, sleepDelayAfterDe // Retry detaching the ENI from the instance err = retry.RetryNWithBackoff(retry.NewSimpleBackoff(time.Millisecond*200, maxBackoffDelay, 0.15, 2.0), maxENIDeleteRetries, func() error { start := time.Now() - _, ec2Err := cache.ec2SVC.DetachNetworkInterface(detachInput) + _, ec2Err := cache.ec2SVC.DetachNetworkInterfaceWithContext(context.Background(), detachInput, userAgent) awsAPILatency.WithLabelValues("DetachNetworkInterface", fmt.Sprint(ec2Err != nil)).Observe(msSince(start)) if ec2Err != nil { awsAPIErrInc("DetachNetworkInterface", ec2Err) @@ -854,7 +857,7 @@ func (cache *EC2InstanceMetadataCache) getENIAttachmentID(eniID string) (*string input := &ec2.DescribeNetworkInterfacesInput{NetworkInterfaceIds: eniIds} start := time.Now() - result, err := cache.ec2SVC.DescribeNetworkInterfaces(input) + result, err := cache.ec2SVC.DescribeNetworkInterfacesWithContext(context.Background(), input, userAgent) awsAPILatency.WithLabelValues("DescribeNetworkInterfaces", fmt.Sprint(err != nil)).Observe(msSince(start)) if err != nil { if aerr, ok := err.(awserr.Error); ok { @@ -889,7 +892,7 @@ func (cache *EC2InstanceMetadataCache) deleteENI(eniName string, maxBackoffDelay } err := retry.RetryNWithBackoff(retry.NewSimpleBackoff(time.Millisecond*500, maxBackoffDelay, 0.15, 2.0), maxENIDeleteRetries, func() error { start := time.Now() - _, ec2Err := cache.ec2SVC.DeleteNetworkInterface(deleteInput) + _, ec2Err := cache.ec2SVC.DeleteNetworkInterfaceWithContext(context.Background(), deleteInput, userAgent) awsAPILatency.WithLabelValues("DeleteNetworkInterface", fmt.Sprint(ec2Err != nil)).Observe(msSince(start)) if ec2Err != nil { if aerr, ok := ec2Err.(awserr.Error); ok { @@ -916,7 +919,7 @@ func (cache *EC2InstanceMetadataCache) GetIPv4sFromEC2(eniID string) (addrList [ input := &ec2.DescribeNetworkInterfacesInput{NetworkInterfaceIds: eniIds} start := time.Now() - result, err := cache.ec2SVC.DescribeNetworkInterfaces(input) + result, err := cache.ec2SVC.DescribeNetworkInterfacesWithContext(context.Background(), input, userAgent) awsAPILatency.WithLabelValues("DescribeNetworkInterfaces", fmt.Sprint(err != nil)).Observe(msSince(start)) if err != nil { if aerr, ok := err.(awserr.Error); ok { @@ -955,7 +958,7 @@ func (cache *EC2InstanceMetadataCache) DescribeAllENIs() ([]ENIMetadata, map[str input := &ec2.DescribeNetworkInterfacesInput{NetworkInterfaceIds: aws.StringSlice(eniIDs)} start := time.Now() - ec2Response, err := cache.ec2SVC.DescribeNetworkInterfaces(input) + ec2Response, err := cache.ec2SVC.DescribeNetworkInterfacesWithContext(context.Background(), input, userAgent) awsAPILatency.WithLabelValues("DescribeNetworkInterfaces", fmt.Sprint(err != nil)).Observe(msSince(start)) if err != nil { if aerr, ok := err.(awserr.Error); ok { @@ -1036,7 +1039,7 @@ func (cache *EC2InstanceMetadataCache) AllocIPAddress(eniID string) error { } start := time.Now() - output, err := cache.ec2SVC.AssignPrivateIpAddresses(input) + output, err := cache.ec2SVC.AssignPrivateIpAddressesWithContext(context.Background(), input, userAgent) awsAPILatency.WithLabelValues("AssignPrivateIpAddresses", fmt.Sprint(err != nil)).Observe(msSince(start)) if err != nil { awsAPIErrInc("AssignPrivateIpAddresses", err) @@ -1064,7 +1067,7 @@ func (cache *EC2InstanceMetadataCache) GetENILimit() (int, error) { if !ok { // Fetch from EC2 API describeInstanceTypesInput := &ec2.DescribeInstanceTypesInput{InstanceTypes: []*string{aws.String(cache.instanceType)}} - output, err := cache.ec2SVC.DescribeInstanceTypes(describeInstanceTypesInput) + output, err := cache.ec2SVC.DescribeInstanceTypesWithContext(context.Background(), describeInstanceTypesInput, userAgent) if err != nil || len(output.InstanceTypes) != 1 { log.Errorf("", err) return 0, errors.New(fmt.Sprintf("Failed calling DescribeInstanceTypes for `%s`: %v", cache.instanceType, err)) @@ -1110,7 +1113,7 @@ func (cache *EC2InstanceMetadataCache) AllocIPAddresses(eniID string, numIPs int } start := time.Now() - output, err := cache.ec2SVC.AssignPrivateIpAddresses(input) + output, err := cache.ec2SVC.AssignPrivateIpAddressesWithContext(context.Background(), input, userAgent) awsAPILatency.WithLabelValues("AssignPrivateIpAddresses", fmt.Sprint(err != nil)).Observe(msSince(start)) if err != nil { log.Errorf("Failed to allocate a private IP addresses on ENI %v: %v", eniID, err) @@ -1129,7 +1132,6 @@ func (cache *EC2InstanceMetadataCache) AllocIPAddresses(eniID string, numIPs int // DeallocIPAddresses allocates numIPs of IP address on an ENI func (cache *EC2InstanceMetadataCache) DeallocIPAddresses(eniID string, ips []string) error { - ctx := context.Background() log.Infof("Trying to unassign the following IPs %s from ENI %s", ips, eniID) var ipsInput []*string for _, ip := range ips { @@ -1142,10 +1144,10 @@ func (cache *EC2InstanceMetadataCache) DeallocIPAddresses(eniID string, ips []st } start := time.Now() - _, err := cache.ec2SVC.UnassignPrivateIpAddressesWithContext(ctx, input) - awsAPILatency.WithLabelValues("UnassignPrivateIpAddressesWithContext", fmt.Sprint(err != nil)).Observe(msSince(start)) + _, err := cache.ec2SVC.UnassignPrivateIpAddressesWithContext(context.Background(), input, userAgent) + awsAPILatency.WithLabelValues("UnassignPrivateIpAddresses", fmt.Sprint(err != nil)).Observe(msSince(start)) if err != nil { - awsAPIErrInc("UnassignPrivateIpAddressesWithContext", err) + awsAPIErrInc("UnassignPrivateIpAddresses", err) log.Errorf("Failed to deallocate a private IP address %v", err) return errors.Wrap(err, fmt.Sprintf("deallocate IP addresses: failed to deallocate private IP addresses: %s", ips)) } @@ -1196,7 +1198,7 @@ func (cache *EC2InstanceMetadataCache) getFilteredListOfNetworkInterfaces() ([]* input := &ec2.DescribeNetworkInterfacesInput{ Filters: []*ec2.Filter{tagFilter, statusFilter}, } - result, err := cache.ec2SVC.DescribeNetworkInterfaces(input) + result, err := cache.ec2SVC.DescribeNetworkInterfacesWithContext(context.Background(), input, userAgent) if err != nil { return nil, errors.Wrap(err, "awsutils: unable to obtain filtered list of network interfaces") } diff --git a/pkg/awsutils/awsutils_test.go b/pkg/awsutils/awsutils_test.go index 31cfc84060..de0e51e948 100644 --- a/pkg/awsutils/awsutils_test.go +++ b/pkg/awsutils/awsutils_test.go @@ -273,7 +273,7 @@ func TestAWSGetFreeDeviceNumberOnErr(t *testing.T) { defer ctrl.Finish() // test error handling - mockEC2.EXPECT().DescribeInstances(gomock.Any()).Return(nil, errors.New("error on DescribeInstances")) + mockEC2.EXPECT().DescribeInstancesWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, errors.New("error on DescribeInstancesWithContext")) ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2} _, err := ins.awsGetFreeDeviceNumber() @@ -298,7 +298,7 @@ func TestAWSGetFreeDeviceNumberNoDevice(t *testing.T) { result := &ec2.DescribeInstancesOutput{ Reservations: []*ec2.Reservation{{Instances: []*ec2.Instance{{NetworkInterfaces: ec2ENIs}}}}} - mockEC2.EXPECT().DescribeInstances(gomock.Any()).Return(result, nil) + mockEC2.EXPECT().DescribeInstancesWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(result, nil) ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2} _, err := ins.awsGetFreeDeviceNumber() @@ -358,7 +358,7 @@ func TestGetENIAttachmentID(t *testing.T) { } for _, tc := range testCases { - mockEC2.EXPECT().DescribeNetworkInterfaces(gomock.Any()).Return(tc.output, tc.awsErr) + mockEC2.EXPECT().DescribeNetworkInterfacesWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(tc.output, tc.awsErr) ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2} id, err := ins.getENIAttachmentID("test-eni") @@ -396,7 +396,7 @@ func TestDescribeAllENIs(t *testing.T) { } for _, tc := range testCases { - mockEC2.EXPECT().DescribeNetworkInterfaces(gomock.Any()).Return(result, tc.awsErr) + mockEC2.EXPECT().DescribeNetworkInterfacesWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(result, tc.awsErr) ins := &EC2InstanceMetadataCache{ec2Metadata: mockMetadata, ec2SVC: mockEC2} _, tags, err := ins.DescribeAllENIs() assert.Equal(t, tc.expErr, err, tc.name) @@ -424,11 +424,11 @@ func TestTagEni(t *testing.T) { ins := &EC2InstanceMetadataCache{ec2Metadata: mockMetadata, ec2SVC: mockEC2} err := ins.initWithEC2Metadata() assert.NoError(t, err) - mockEC2.EXPECT().CreateTags(gomock.Any()).Return(nil, errors.New("tagging failed")) - mockEC2.EXPECT().CreateTags(gomock.Any()).Return(nil, errors.New("tagging failed")) - mockEC2.EXPECT().CreateTags(gomock.Any()).Return(nil, errors.New("tagging failed")) - mockEC2.EXPECT().CreateTags(gomock.Any()).Return(nil, errors.New("tagging failed")) - mockEC2.EXPECT().CreateTags(gomock.Any()).Return(nil, nil) + mockEC2.EXPECT().CreateTagsWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, errors.New("tagging failed")) + mockEC2.EXPECT().CreateTagsWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, errors.New("tagging failed")) + mockEC2.EXPECT().CreateTagsWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, errors.New("tagging failed")) + mockEC2.EXPECT().CreateTagsWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, errors.New("tagging failed")) + mockEC2.EXPECT().CreateTagsWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil) ins.tagENI(eniID, time.Millisecond) assert.NoError(t, err) } @@ -449,7 +449,7 @@ func TestAdditionalTagsEni(t *testing.T) { NetworkInterfaces: []*ec2.NetworkInterface{{TagSet: []*ec2.Tag{&tag}}}} ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2} - mockEC2.EXPECT().CreateTags(gomock.Any()).Return(nil, nil) + mockEC2.EXPECT().CreateTagsWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil) ins.tagENI(currentENIID, time.Millisecond) // Verify the tags are registered. @@ -488,7 +488,7 @@ func TestAllocENI(t *testing.T) { cureniID := eniID eni := ec2.CreateNetworkInterfaceOutput{NetworkInterface: &ec2.NetworkInterface{NetworkInterfaceId: &cureniID}} - mockEC2.EXPECT().CreateNetworkInterface(gomock.Any()).Return(&eni, nil) + mockEC2.EXPECT().CreateNetworkInterfaceWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(&eni, nil) // 2 ENIs, uses device number 0 3, expect to find free at 1 ec2ENIs := make([]*ec2.InstanceNetworkInterface, 0) @@ -507,13 +507,13 @@ func TestAllocENI(t *testing.T) { result := &ec2.DescribeInstancesOutput{ Reservations: []*ec2.Reservation{{Instances: []*ec2.Instance{{NetworkInterfaces: ec2ENIs}}}}} - mockEC2.EXPECT().DescribeInstances(gomock.Any()).Return(result, nil) + mockEC2.EXPECT().DescribeInstancesWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(result, nil) attachmentID := "eni-attach-58ddda9d" attachResult := &ec2.AttachNetworkInterfaceOutput{ AttachmentId: &attachmentID} - mockEC2.EXPECT().AttachNetworkInterface(gomock.Any()).Return(attachResult, nil) - mockEC2.EXPECT().CreateTags(gomock.Any()).Return(nil, nil) - mockEC2.EXPECT().ModifyNetworkInterfaceAttribute(gomock.Any()).Return(nil, nil) + mockEC2.EXPECT().AttachNetworkInterfaceWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(attachResult, nil) + mockEC2.EXPECT().CreateTagsWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil) + mockEC2.EXPECT().ModifyNetworkInterfaceAttributeWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil) ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2} _, err := ins.AllocENI(false, nil, "") @@ -526,7 +526,7 @@ func TestAllocENINoFreeDevice(t *testing.T) { cureniID := eniID eni := ec2.CreateNetworkInterfaceOutput{NetworkInterface: &ec2.NetworkInterface{NetworkInterfaceId: &cureniID}} - mockEC2.EXPECT().CreateNetworkInterface(gomock.Any()).Return(&eni, nil) + mockEC2.EXPECT().CreateNetworkInterfaceWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(&eni, nil) // test no free index ec2ENIs := make([]*ec2.InstanceNetworkInterface, 0) @@ -542,8 +542,8 @@ func TestAllocENINoFreeDevice(t *testing.T) { result := &ec2.DescribeInstancesOutput{ Reservations: []*ec2.Reservation{{Instances: []*ec2.Instance{{NetworkInterfaces: ec2ENIs}}}}} - mockEC2.EXPECT().DescribeInstances(gomock.Any()).Return(result, nil) - mockEC2.EXPECT().DeleteNetworkInterface(gomock.Any()).Return(nil, nil) + mockEC2.EXPECT().DescribeInstancesWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(result, nil) + mockEC2.EXPECT().DeleteNetworkInterfaceWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil) ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2} _, err := ins.AllocENI(false, nil, "") @@ -556,7 +556,7 @@ func TestAllocENIMaxReached(t *testing.T) { cureniID := eniID eni := ec2.CreateNetworkInterfaceOutput{NetworkInterface: &ec2.NetworkInterface{NetworkInterfaceId: &cureniID}} - mockEC2.EXPECT().CreateNetworkInterface(gomock.Any()).Return(&eni, nil) + mockEC2.EXPECT().CreateNetworkInterfaceWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(&eni, nil) // 2 ENIs, uses device number 0 3, expect to find free at 1 ec2ENIs := make([]*ec2.InstanceNetworkInterface, 0) @@ -575,9 +575,9 @@ func TestAllocENIMaxReached(t *testing.T) { result := &ec2.DescribeInstancesOutput{ Reservations: []*ec2.Reservation{{Instances: []*ec2.Instance{{NetworkInterfaces: ec2ENIs}}}}} - mockEC2.EXPECT().DescribeInstances(gomock.Any()).Return(result, nil) - mockEC2.EXPECT().AttachNetworkInterface(gomock.Any()).Return(nil, errors.New("AttachmentLimitExceeded")) - mockEC2.EXPECT().DeleteNetworkInterface(gomock.Any()).Return(nil, nil) + mockEC2.EXPECT().DescribeInstancesWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(result, nil) + mockEC2.EXPECT().AttachNetworkInterfaceWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, errors.New("AttachmentLimitExceeded")) + mockEC2.EXPECT().DeleteNetworkInterfaceWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil) ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2} _, err := ins.AllocENI(false, nil, "") @@ -592,9 +592,9 @@ func TestFreeENI(t *testing.T) { attachment := &ec2.NetworkInterfaceAttachment{AttachmentId: &attachmentID} result := &ec2.DescribeNetworkInterfacesOutput{ NetworkInterfaces: []*ec2.NetworkInterface{{Attachment: attachment}}} - mockEC2.EXPECT().DescribeNetworkInterfaces(gomock.Any()).Return(result, nil) - mockEC2.EXPECT().DetachNetworkInterface(gomock.Any()).Return(nil, nil) - mockEC2.EXPECT().DeleteNetworkInterface(gomock.Any()).Return(nil, nil) + mockEC2.EXPECT().DescribeNetworkInterfacesWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(result, nil) + mockEC2.EXPECT().DetachNetworkInterfaceWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil) + mockEC2.EXPECT().DeleteNetworkInterfaceWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil) ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2} err := ins.freeENI("test-eni", time.Millisecond, time.Millisecond) @@ -609,12 +609,12 @@ func TestFreeENIRetry(t *testing.T) { attachment := &ec2.NetworkInterfaceAttachment{AttachmentId: &attachmentID} result := &ec2.DescribeNetworkInterfacesOutput{ NetworkInterfaces: []*ec2.NetworkInterface{{Attachment: attachment}}} - mockEC2.EXPECT().DescribeNetworkInterfaces(gomock.Any()).Return(result, nil) + mockEC2.EXPECT().DescribeNetworkInterfacesWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(result, nil) // retry 2 times - mockEC2.EXPECT().DetachNetworkInterface(gomock.Any()).Return(nil, nil) - mockEC2.EXPECT().DeleteNetworkInterface(gomock.Any()).Return(nil, errors.New("testing retrying delete")) - mockEC2.EXPECT().DeleteNetworkInterface(gomock.Any()).Return(nil, nil) + mockEC2.EXPECT().DetachNetworkInterfaceWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil) + mockEC2.EXPECT().DeleteNetworkInterfaceWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, errors.New("testing retrying delete")) + mockEC2.EXPECT().DeleteNetworkInterfaceWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil) ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2} err := ins.freeENI("test-eni", time.Millisecond, time.Millisecond) @@ -629,11 +629,11 @@ func TestFreeENIRetryMax(t *testing.T) { attachment := &ec2.NetworkInterfaceAttachment{AttachmentId: &attachmentID} result := &ec2.DescribeNetworkInterfacesOutput{ NetworkInterfaces: []*ec2.NetworkInterface{{Attachment: attachment}}} - mockEC2.EXPECT().DescribeNetworkInterfaces(gomock.Any()).Return(result, nil) - mockEC2.EXPECT().DetachNetworkInterface(gomock.Any()).Return(nil, nil) + mockEC2.EXPECT().DescribeNetworkInterfacesWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(result, nil) + mockEC2.EXPECT().DetachNetworkInterfaceWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil) for i := 0; i < maxENIDeleteRetries; i++ { - mockEC2.EXPECT().DeleteNetworkInterface(gomock.Any()).Return(nil, errors.New("testing retrying delete")) + mockEC2.EXPECT().DeleteNetworkInterfaceWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, errors.New("testing retrying delete")) } ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2} @@ -645,7 +645,7 @@ func TestFreeENIDescribeErr(t *testing.T) { ctrl, _, mockEC2 := setup(t) defer ctrl.Finish() - mockEC2.EXPECT().DescribeNetworkInterfaces(gomock.Any()).Return(nil, errors.New("Error on DescribeNetworkInterfaces")) + mockEC2.EXPECT().DescribeNetworkInterfacesWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, errors.New("Error on DescribeNetworkInterfacesWithContext")) ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2} err := ins.FreeENI("test-eni") @@ -655,7 +655,7 @@ func TestFreeENIDescribeErr(t *testing.T) { func TestDescribeInstanceTypes(t *testing.T) { ctrl, _, mockEC2 := setup(t) defer ctrl.Finish() - mockEC2.EXPECT().DescribeInstanceTypes(gomock.Any()).Return(&ec2.DescribeInstanceTypesOutput{ + mockEC2.EXPECT().DescribeInstanceTypesWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(&ec2.DescribeInstanceTypesOutput{ InstanceTypes: []*ec2.InstanceTypeInfo{ {InstanceType: aws.String("not-there"), NetworkInfo: &ec2.NetworkInfo{ MaximumNetworkInterfaces: aws.Int64(9), @@ -677,7 +677,7 @@ func TestAllocIPAddress(t *testing.T) { ctrl, _, mockEC2 := setup(t) defer ctrl.Finish() - mockEC2.EXPECT().AssignPrivateIpAddresses(gomock.Any()).Return(&ec2.AssignPrivateIpAddressesOutput{}, nil) + mockEC2.EXPECT().AssignPrivateIpAddressesWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(&ec2.AssignPrivateIpAddressesOutput{}, nil) ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2} err := ins.AllocIPAddress("eni-id") @@ -688,7 +688,7 @@ func TestAllocIPAddressOnErr(t *testing.T) { ctrl, _, mockEC2 := setup(t) defer ctrl.Finish() - mockEC2.EXPECT().AssignPrivateIpAddresses(gomock.Any()).Return(nil, errors.New("Error on AssignPrivateIpAddresses")) + mockEC2.EXPECT().AssignPrivateIpAddressesWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, errors.New("Error on AssignPrivateIpAddressesWithContext")) ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2} err := ins.AllocIPAddress("eni-id") @@ -704,7 +704,7 @@ func TestAllocIPAddresses(t *testing.T) { NetworkInterfaceId: aws.String("eni-id"), SecondaryPrivateIpAddressCount: aws.Int64(5), } - mockEC2.EXPECT().AssignPrivateIpAddresses(input).Return(nil, nil) + mockEC2.EXPECT().AssignPrivateIpAddressesWithContext(gomock.Any(), input, gomock.Any()).Return(nil, nil) ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2, instanceType: "c5n.18xlarge"} err := ins.AllocIPAddresses("eni-id", 5) @@ -715,7 +715,7 @@ func TestAllocIPAddresses(t *testing.T) { NetworkInterfaceId: aws.String("eni-id"), SecondaryPrivateIpAddressCount: aws.Int64(49), } - mockEC2.EXPECT().AssignPrivateIpAddresses(input).Return(nil, nil) + mockEC2.EXPECT().AssignPrivateIpAddressesWithContext(gomock.Any(), input, gomock.Any()).Return(nil, nil) ins = &EC2InstanceMetadataCache{ec2SVC: mockEC2, instanceType: "c5n.18xlarge"} err = ins.AllocIPAddresses("eni-id", 50) @@ -738,7 +738,7 @@ func TestEC2InstanceMetadataCache_getFilteredListOfNetworkInterfaces_OneResult(t attachment := &ec2.NetworkInterfaceAttachment{AttachmentId: &attachmentID} result := &ec2.DescribeNetworkInterfacesOutput{ NetworkInterfaces: []*ec2.NetworkInterface{{Attachment: attachment, Status: &status, TagSet: []*ec2.Tag{&tag}, Description: &description}}} - mockEC2.EXPECT().DescribeNetworkInterfaces(gomock.Any()).Return(result, nil) + mockEC2.EXPECT().DescribeNetworkInterfacesWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(result, nil) ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2} got, err := ins.getFilteredListOfNetworkInterfaces() @@ -752,7 +752,7 @@ func TestEC2InstanceMetadataCache_getFilteredListOfNetworkInterfaces_NoResult(t result := &ec2.DescribeNetworkInterfacesOutput{ NetworkInterfaces: []*ec2.NetworkInterface{}} - mockEC2.EXPECT().DescribeNetworkInterfaces(gomock.Any()).Return(result, nil) + mockEC2.EXPECT().DescribeNetworkInterfacesWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(result, nil) ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2} got, err := ins.getFilteredListOfNetworkInterfaces() @@ -764,7 +764,7 @@ func TestEC2InstanceMetadataCache_getFilteredListOfNetworkInterfaces_Error(t *te ctrl, _, mockEC2 := setup(t) defer ctrl.Finish() - mockEC2.EXPECT().DescribeNetworkInterfaces(gomock.Any()).Return(nil, errors.New("dummy error")) + mockEC2.EXPECT().DescribeNetworkInterfacesWithContext(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, errors.New("dummy error")) ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2} got, err := ins.getFilteredListOfNetworkInterfaces() diff --git a/pkg/ec2wrapper/client.go b/pkg/ec2wrapper/client.go index ebb05d704c..b5033607d6 100644 --- a/pkg/ec2wrapper/client.go +++ b/pkg/ec2wrapper/client.go @@ -21,17 +21,17 @@ import ( ) type EC2 interface { - CreateNetworkInterface(input *ec2svc.CreateNetworkInterfaceInput) (*ec2svc.CreateNetworkInterfaceOutput, error) - DescribeInstances(input *ec2svc.DescribeInstancesInput) (*ec2svc.DescribeInstancesOutput, error) - DescribeInstanceTypes(input *ec2svc.DescribeInstanceTypesInput) (*ec2svc.DescribeInstanceTypesOutput, error) - AttachNetworkInterface(input *ec2svc.AttachNetworkInterfaceInput) (*ec2svc.AttachNetworkInterfaceOutput, error) - DeleteNetworkInterface(input *ec2svc.DeleteNetworkInterfaceInput) (*ec2svc.DeleteNetworkInterfaceOutput, error) - DetachNetworkInterface(input *ec2svc.DetachNetworkInterfaceInput) (*ec2svc.DetachNetworkInterfaceOutput, error) - AssignPrivateIpAddresses(input *ec2svc.AssignPrivateIpAddressesInput) (*ec2svc.AssignPrivateIpAddressesOutput, error) + CreateNetworkInterfaceWithContext(ctx aws.Context, input *ec2svc.CreateNetworkInterfaceInput, opts ...request.Option) (*ec2svc.CreateNetworkInterfaceOutput, error) + DescribeInstancesWithContext(ctx aws.Context, input *ec2svc.DescribeInstancesInput, opts ...request.Option) (*ec2svc.DescribeInstancesOutput, error) + DescribeInstanceTypesWithContext(ctx aws.Context, input *ec2svc.DescribeInstanceTypesInput, opts ...request.Option) (*ec2svc.DescribeInstanceTypesOutput, error) + AttachNetworkInterfaceWithContext(ctx aws.Context, input *ec2svc.AttachNetworkInterfaceInput, opts ...request.Option) (*ec2svc.AttachNetworkInterfaceOutput, error) + DeleteNetworkInterfaceWithContext(ctx aws.Context, input *ec2svc.DeleteNetworkInterfaceInput, opts ...request.Option) (*ec2svc.DeleteNetworkInterfaceOutput, error) + DetachNetworkInterfaceWithContext(ctx aws.Context, input *ec2svc.DetachNetworkInterfaceInput, opts ...request.Option) (*ec2svc.DetachNetworkInterfaceOutput, error) + AssignPrivateIpAddressesWithContext(ctx aws.Context, input *ec2svc.AssignPrivateIpAddressesInput, opts ...request.Option) (*ec2svc.AssignPrivateIpAddressesOutput, error) UnassignPrivateIpAddressesWithContext(ctx aws.Context, input *ec2svc.UnassignPrivateIpAddressesInput, opts ...request.Option) (*ec2svc.UnassignPrivateIpAddressesOutput, error) - DescribeNetworkInterfaces(input *ec2svc.DescribeNetworkInterfacesInput) (*ec2svc.DescribeNetworkInterfacesOutput, error) - ModifyNetworkInterfaceAttribute(input *ec2svc.ModifyNetworkInterfaceAttributeInput) (*ec2svc.ModifyNetworkInterfaceAttributeOutput, error) - CreateTags(input *ec2svc.CreateTagsInput) (*ec2svc.CreateTagsOutput, error) + DescribeNetworkInterfacesWithContext(ctx aws.Context, input *ec2svc.DescribeNetworkInterfacesInput, opts ...request.Option) (*ec2svc.DescribeNetworkInterfacesOutput, error) + ModifyNetworkInterfaceAttributeWithContext(ctx aws.Context, input *ec2svc.ModifyNetworkInterfaceAttributeInput, opts ...request.Option) (*ec2svc.ModifyNetworkInterfaceAttributeOutput, error) + CreateTagsWithContext(ctx aws.Context, input *ec2svc.CreateTagsInput, opts ...request.Option) (*ec2svc.CreateTagsOutput, error) } func New(sess *session.Session) EC2 { diff --git a/pkg/ec2wrapper/mocks/ec2wrapper_mocks.go b/pkg/ec2wrapper/mocks/ec2wrapper_mocks.go index da90aa12d7..ecc2ebfdca 100644 --- a/pkg/ec2wrapper/mocks/ec2wrapper_mocks.go +++ b/pkg/ec2wrapper/mocks/ec2wrapper_mocks.go @@ -50,154 +50,204 @@ func (m *MockEC2) EXPECT() *MockEC2MockRecorder { return m.recorder } -// AssignPrivateIpAddresses mocks base method -func (m *MockEC2) AssignPrivateIpAddresses(arg0 *ec2.AssignPrivateIpAddressesInput) (*ec2.AssignPrivateIpAddressesOutput, error) { +// AssignPrivateIpAddressesWithContext mocks base method +func (m *MockEC2) AssignPrivateIpAddressesWithContext(arg0 context.Context, arg1 *ec2.AssignPrivateIpAddressesInput, arg2 ...request.Option) (*ec2.AssignPrivateIpAddressesOutput, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AssignPrivateIpAddresses", arg0) + varargs := []interface{}{arg0, arg1} + for _, a := range arg2 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "AssignPrivateIpAddressesWithContext", varargs...) ret0, _ := ret[0].(*ec2.AssignPrivateIpAddressesOutput) ret1, _ := ret[1].(error) return ret0, ret1 } -// AssignPrivateIpAddresses indicates an expected call of AssignPrivateIpAddresses -func (mr *MockEC2MockRecorder) AssignPrivateIpAddresses(arg0 interface{}) *gomock.Call { +// AssignPrivateIpAddressesWithContext indicates an expected call of AssignPrivateIpAddressesWithContext +func (mr *MockEC2MockRecorder) AssignPrivateIpAddressesWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AssignPrivateIpAddresses", reflect.TypeOf((*MockEC2)(nil).AssignPrivateIpAddresses), arg0) + varargs := append([]interface{}{arg0, arg1}, arg2...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AssignPrivateIpAddressesWithContext", reflect.TypeOf((*MockEC2)(nil).AssignPrivateIpAddressesWithContext), varargs...) } -// AttachNetworkInterface mocks base method -func (m *MockEC2) AttachNetworkInterface(arg0 *ec2.AttachNetworkInterfaceInput) (*ec2.AttachNetworkInterfaceOutput, error) { +// AttachNetworkInterfaceWithContext mocks base method +func (m *MockEC2) AttachNetworkInterfaceWithContext(arg0 context.Context, arg1 *ec2.AttachNetworkInterfaceInput, arg2 ...request.Option) (*ec2.AttachNetworkInterfaceOutput, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AttachNetworkInterface", arg0) + varargs := []interface{}{arg0, arg1} + for _, a := range arg2 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "AttachNetworkInterfaceWithContext", varargs...) ret0, _ := ret[0].(*ec2.AttachNetworkInterfaceOutput) ret1, _ := ret[1].(error) return ret0, ret1 } -// AttachNetworkInterface indicates an expected call of AttachNetworkInterface -func (mr *MockEC2MockRecorder) AttachNetworkInterface(arg0 interface{}) *gomock.Call { +// AttachNetworkInterfaceWithContext indicates an expected call of AttachNetworkInterfaceWithContext +func (mr *MockEC2MockRecorder) AttachNetworkInterfaceWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AttachNetworkInterface", reflect.TypeOf((*MockEC2)(nil).AttachNetworkInterface), arg0) + varargs := append([]interface{}{arg0, arg1}, arg2...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AttachNetworkInterfaceWithContext", reflect.TypeOf((*MockEC2)(nil).AttachNetworkInterfaceWithContext), varargs...) } -// CreateNetworkInterface mocks base method -func (m *MockEC2) CreateNetworkInterface(arg0 *ec2.CreateNetworkInterfaceInput) (*ec2.CreateNetworkInterfaceOutput, error) { +// CreateNetworkInterfaceWithContext mocks base method +func (m *MockEC2) CreateNetworkInterfaceWithContext(arg0 context.Context, arg1 *ec2.CreateNetworkInterfaceInput, arg2 ...request.Option) (*ec2.CreateNetworkInterfaceOutput, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateNetworkInterface", arg0) + varargs := []interface{}{arg0, arg1} + for _, a := range arg2 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CreateNetworkInterfaceWithContext", varargs...) ret0, _ := ret[0].(*ec2.CreateNetworkInterfaceOutput) ret1, _ := ret[1].(error) return ret0, ret1 } -// CreateNetworkInterface indicates an expected call of CreateNetworkInterface -func (mr *MockEC2MockRecorder) CreateNetworkInterface(arg0 interface{}) *gomock.Call { +// CreateNetworkInterfaceWithContext indicates an expected call of CreateNetworkInterfaceWithContext +func (mr *MockEC2MockRecorder) CreateNetworkInterfaceWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateNetworkInterface", reflect.TypeOf((*MockEC2)(nil).CreateNetworkInterface), arg0) + varargs := append([]interface{}{arg0, arg1}, arg2...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateNetworkInterfaceWithContext", reflect.TypeOf((*MockEC2)(nil).CreateNetworkInterfaceWithContext), varargs...) } -// CreateTags mocks base method -func (m *MockEC2) CreateTags(arg0 *ec2.CreateTagsInput) (*ec2.CreateTagsOutput, error) { +// CreateTagsWithContext mocks base method +func (m *MockEC2) CreateTagsWithContext(arg0 context.Context, arg1 *ec2.CreateTagsInput, arg2 ...request.Option) (*ec2.CreateTagsOutput, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateTags", arg0) + varargs := []interface{}{arg0, arg1} + for _, a := range arg2 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CreateTagsWithContext", varargs...) ret0, _ := ret[0].(*ec2.CreateTagsOutput) ret1, _ := ret[1].(error) return ret0, ret1 } -// CreateTags indicates an expected call of CreateTags -func (mr *MockEC2MockRecorder) CreateTags(arg0 interface{}) *gomock.Call { +// CreateTagsWithContext indicates an expected call of CreateTagsWithContext +func (mr *MockEC2MockRecorder) CreateTagsWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateTags", reflect.TypeOf((*MockEC2)(nil).CreateTags), arg0) + varargs := append([]interface{}{arg0, arg1}, arg2...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateTagsWithContext", reflect.TypeOf((*MockEC2)(nil).CreateTagsWithContext), varargs...) } -// DeleteNetworkInterface mocks base method -func (m *MockEC2) DeleteNetworkInterface(arg0 *ec2.DeleteNetworkInterfaceInput) (*ec2.DeleteNetworkInterfaceOutput, error) { +// DeleteNetworkInterfaceWithContext mocks base method +func (m *MockEC2) DeleteNetworkInterfaceWithContext(arg0 context.Context, arg1 *ec2.DeleteNetworkInterfaceInput, arg2 ...request.Option) (*ec2.DeleteNetworkInterfaceOutput, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DeleteNetworkInterface", arg0) + varargs := []interface{}{arg0, arg1} + for _, a := range arg2 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DeleteNetworkInterfaceWithContext", varargs...) ret0, _ := ret[0].(*ec2.DeleteNetworkInterfaceOutput) ret1, _ := ret[1].(error) return ret0, ret1 } -// DeleteNetworkInterface indicates an expected call of DeleteNetworkInterface -func (mr *MockEC2MockRecorder) DeleteNetworkInterface(arg0 interface{}) *gomock.Call { +// DeleteNetworkInterfaceWithContext indicates an expected call of DeleteNetworkInterfaceWithContext +func (mr *MockEC2MockRecorder) DeleteNetworkInterfaceWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteNetworkInterface", reflect.TypeOf((*MockEC2)(nil).DeleteNetworkInterface), arg0) + varargs := append([]interface{}{arg0, arg1}, arg2...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteNetworkInterfaceWithContext", reflect.TypeOf((*MockEC2)(nil).DeleteNetworkInterfaceWithContext), varargs...) } -// DescribeInstanceTypes mocks base method -func (m *MockEC2) DescribeInstanceTypes(arg0 *ec2.DescribeInstanceTypesInput) (*ec2.DescribeInstanceTypesOutput, error) { +// DescribeInstanceTypesWithContext mocks base method +func (m *MockEC2) DescribeInstanceTypesWithContext(arg0 context.Context, arg1 *ec2.DescribeInstanceTypesInput, arg2 ...request.Option) (*ec2.DescribeInstanceTypesOutput, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DescribeInstanceTypes", arg0) + varargs := []interface{}{arg0, arg1} + for _, a := range arg2 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DescribeInstanceTypesWithContext", varargs...) ret0, _ := ret[0].(*ec2.DescribeInstanceTypesOutput) ret1, _ := ret[1].(error) return ret0, ret1 } -// DescribeInstanceTypes indicates an expected call of DescribeInstanceTypes -func (mr *MockEC2MockRecorder) DescribeInstanceTypes(arg0 interface{}) *gomock.Call { +// DescribeInstanceTypesWithContext indicates an expected call of DescribeInstanceTypesWithContext +func (mr *MockEC2MockRecorder) DescribeInstanceTypesWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DescribeInstanceTypes", reflect.TypeOf((*MockEC2)(nil).DescribeInstanceTypes), arg0) + varargs := append([]interface{}{arg0, arg1}, arg2...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DescribeInstanceTypesWithContext", reflect.TypeOf((*MockEC2)(nil).DescribeInstanceTypesWithContext), varargs...) } -// DescribeInstances mocks base method -func (m *MockEC2) DescribeInstances(arg0 *ec2.DescribeInstancesInput) (*ec2.DescribeInstancesOutput, error) { +// DescribeInstancesWithContext mocks base method +func (m *MockEC2) DescribeInstancesWithContext(arg0 context.Context, arg1 *ec2.DescribeInstancesInput, arg2 ...request.Option) (*ec2.DescribeInstancesOutput, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DescribeInstances", arg0) + varargs := []interface{}{arg0, arg1} + for _, a := range arg2 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DescribeInstancesWithContext", varargs...) ret0, _ := ret[0].(*ec2.DescribeInstancesOutput) ret1, _ := ret[1].(error) return ret0, ret1 } -// DescribeInstances indicates an expected call of DescribeInstances -func (mr *MockEC2MockRecorder) DescribeInstances(arg0 interface{}) *gomock.Call { +// DescribeInstancesWithContext indicates an expected call of DescribeInstancesWithContext +func (mr *MockEC2MockRecorder) DescribeInstancesWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DescribeInstances", reflect.TypeOf((*MockEC2)(nil).DescribeInstances), arg0) + varargs := append([]interface{}{arg0, arg1}, arg2...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DescribeInstancesWithContext", reflect.TypeOf((*MockEC2)(nil).DescribeInstancesWithContext), varargs...) } -// DescribeNetworkInterfaces mocks base method -func (m *MockEC2) DescribeNetworkInterfaces(arg0 *ec2.DescribeNetworkInterfacesInput) (*ec2.DescribeNetworkInterfacesOutput, error) { +// DescribeNetworkInterfacesWithContext mocks base method +func (m *MockEC2) DescribeNetworkInterfacesWithContext(arg0 context.Context, arg1 *ec2.DescribeNetworkInterfacesInput, arg2 ...request.Option) (*ec2.DescribeNetworkInterfacesOutput, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DescribeNetworkInterfaces", arg0) + varargs := []interface{}{arg0, arg1} + for _, a := range arg2 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DescribeNetworkInterfacesWithContext", varargs...) ret0, _ := ret[0].(*ec2.DescribeNetworkInterfacesOutput) ret1, _ := ret[1].(error) return ret0, ret1 } -// DescribeNetworkInterfaces indicates an expected call of DescribeNetworkInterfaces -func (mr *MockEC2MockRecorder) DescribeNetworkInterfaces(arg0 interface{}) *gomock.Call { +// DescribeNetworkInterfacesWithContext indicates an expected call of DescribeNetworkInterfacesWithContext +func (mr *MockEC2MockRecorder) DescribeNetworkInterfacesWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DescribeNetworkInterfaces", reflect.TypeOf((*MockEC2)(nil).DescribeNetworkInterfaces), arg0) + varargs := append([]interface{}{arg0, arg1}, arg2...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DescribeNetworkInterfacesWithContext", reflect.TypeOf((*MockEC2)(nil).DescribeNetworkInterfacesWithContext), varargs...) } -// DetachNetworkInterface mocks base method -func (m *MockEC2) DetachNetworkInterface(arg0 *ec2.DetachNetworkInterfaceInput) (*ec2.DetachNetworkInterfaceOutput, error) { +// DetachNetworkInterfaceWithContext mocks base method +func (m *MockEC2) DetachNetworkInterfaceWithContext(arg0 context.Context, arg1 *ec2.DetachNetworkInterfaceInput, arg2 ...request.Option) (*ec2.DetachNetworkInterfaceOutput, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DetachNetworkInterface", arg0) + varargs := []interface{}{arg0, arg1} + for _, a := range arg2 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "DetachNetworkInterfaceWithContext", varargs...) ret0, _ := ret[0].(*ec2.DetachNetworkInterfaceOutput) ret1, _ := ret[1].(error) return ret0, ret1 } -// DetachNetworkInterface indicates an expected call of DetachNetworkInterface -func (mr *MockEC2MockRecorder) DetachNetworkInterface(arg0 interface{}) *gomock.Call { +// DetachNetworkInterfaceWithContext indicates an expected call of DetachNetworkInterfaceWithContext +func (mr *MockEC2MockRecorder) DetachNetworkInterfaceWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DetachNetworkInterface", reflect.TypeOf((*MockEC2)(nil).DetachNetworkInterface), arg0) + varargs := append([]interface{}{arg0, arg1}, arg2...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DetachNetworkInterfaceWithContext", reflect.TypeOf((*MockEC2)(nil).DetachNetworkInterfaceWithContext), varargs...) } -// ModifyNetworkInterfaceAttribute mocks base method -func (m *MockEC2) ModifyNetworkInterfaceAttribute(arg0 *ec2.ModifyNetworkInterfaceAttributeInput) (*ec2.ModifyNetworkInterfaceAttributeOutput, error) { +// ModifyNetworkInterfaceAttributeWithContext mocks base method +func (m *MockEC2) ModifyNetworkInterfaceAttributeWithContext(arg0 context.Context, arg1 *ec2.ModifyNetworkInterfaceAttributeInput, arg2 ...request.Option) (*ec2.ModifyNetworkInterfaceAttributeOutput, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ModifyNetworkInterfaceAttribute", arg0) + varargs := []interface{}{arg0, arg1} + for _, a := range arg2 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ModifyNetworkInterfaceAttributeWithContext", varargs...) ret0, _ := ret[0].(*ec2.ModifyNetworkInterfaceAttributeOutput) ret1, _ := ret[1].(error) return ret0, ret1 } -// ModifyNetworkInterfaceAttribute indicates an expected call of ModifyNetworkInterfaceAttribute -func (mr *MockEC2MockRecorder) ModifyNetworkInterfaceAttribute(arg0 interface{}) *gomock.Call { +// ModifyNetworkInterfaceAttributeWithContext indicates an expected call of ModifyNetworkInterfaceAttributeWithContext +func (mr *MockEC2MockRecorder) ModifyNetworkInterfaceAttributeWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ModifyNetworkInterfaceAttribute", reflect.TypeOf((*MockEC2)(nil).ModifyNetworkInterfaceAttribute), arg0) + varargs := append([]interface{}{arg0, arg1}, arg2...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ModifyNetworkInterfaceAttributeWithContext", reflect.TypeOf((*MockEC2)(nil).ModifyNetworkInterfaceAttributeWithContext), varargs...) } // UnassignPrivateIpAddressesWithContext mocks base method