Skip to content

Commit

Permalink
Code refactor - merge ENI's secondary and prefix store into single st…
Browse files Browse the repository at this point in the history
…ore of CIDRs (#1471)

* Code refactor - merge to single DB

* remove few debugs

* remove prefix store files

* PR comments

* Fix up CR comments

* formatting

* Updated UT cases

* UT and formatting

* Minor fixes

* Minor comments

* Updated /32 store term

* remove unused code
  • Loading branch information
jayanthvn authored May 27, 2021
1 parent 604d00c commit 9681724
Show file tree
Hide file tree
Showing 9 changed files with 634 additions and 1,244 deletions.
9 changes: 5 additions & 4 deletions pkg/awsutils/awsutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ func TestAllocPrefixAddresses(t *testing.T) {
}
mockEC2.EXPECT().AssignPrivateIpAddressesWithContext(gomock.Any(), input, gomock.Any()).Return(nil, nil)

ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2, instanceType: "c5n.18xlarge", ipv4PrefixDelegation: true}
ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2, instanceType: "c5n.18xlarge", useIPv4PrefixDelegation: true}
err := ins.AllocIPAddresses(eniID, 1)
assert.NoError(t, err)

Expand All @@ -756,7 +756,7 @@ func TestAllocPrefixesAlreadyFull(t *testing.T) {
NetworkInterfaceId: aws.String(eniID),
Ipv4PrefixCount: aws.Int64(1),
}
ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2, instanceType: "t3.xlarge", ipv4PrefixDelegation: true}
ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2, instanceType: "t3.xlarge", useIPv4PrefixDelegation: true}

retErr := awserr.New("PrivateIpAddressLimitExceeded", "Too many IPs already allocated", nil)
mockEC2.EXPECT().AssignPrivateIpAddressesWithContext(gomock.Any(), input, gomock.Any()).Return(nil, retErr)
Expand Down Expand Up @@ -879,7 +879,8 @@ func TestEC2InstanceMetadataCache_waitForENIAndIPsAttached(t *testing.T) {
PrivateIpAddress: &secondaryIP2,
},
},
IPv4Prefixes: make([]*ec2.Ipv4PrefixSpecification, 0),
//IPv4Prefixes: make([]*ec2.Ipv4PrefixSpecification, 0),
IPv4Prefixes: nil,
}
eniList := []ENIMetadata{eni1Metadata, eni2Metadata}
tests := []struct {
Expand Down Expand Up @@ -983,7 +984,7 @@ func TestEC2InstanceMetadataCache_waitForENIAndPrefixesAttached(t *testing.T) {
metadataMACPath + eni2MAC + metadataIPv4s: eniIPs,
metadataMACPath + eni2MAC + metadataIPv4Prefixes: eniPrefixes,
})
cache := &EC2InstanceMetadataCache{imds: TypedIMDS{mockMetadata}, ec2SVC: mockEC2, ipv4PrefixDelegation: true}
cache := &EC2InstanceMetadataCache{imds: TypedIMDS{mockMetadata}, ec2SVC: mockEC2, useIPv4PrefixDelegation: true}
gotEniMetadata, err := cache.waitForENIAndIPsAttached(tt.args.eni, tt.args.wantedSecondaryIPs, tt.args.maxBackoffDelay)
if (err != nil) != tt.wantErr {
t.Errorf("waitForENIAndIPsAttached() error = %v, wantErr %v", err, tt.wantErr)
Expand Down
Loading

0 comments on commit 9681724

Please sign in to comment.