Skip to content

Commit b5c6169

Browse files
authored
Mimic VPC-RC limit struture (#2516)
1 parent d77caf0 commit b5c6169

File tree

3 files changed

+10515
-759
lines changed

3 files changed

+10515
-759
lines changed

pkg/awsutils/awsutils.go

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,21 @@ type ENIMetadata struct {
277277
IPv6Prefixes []*ec2.Ipv6PrefixSpecification
278278
}
279279

280+
type NetworkCard struct {
281+
// max number of interfaces supported per card
282+
MaximumNetworkInterfaces int64
283+
// the index of current card
284+
NetworkCardIndex int64
285+
}
286+
280287
// InstanceTypeLimits keeps track of limits for an instance type
281288
type InstanceTypeLimits struct {
282-
ENILimit int
283-
IPv4Limit int
284-
HypervisorType string
285-
IsBareMetal bool
289+
ENILimit int
290+
IPv4Limit int
291+
NetworkCards []NetworkCard
292+
HypervisorType string
293+
IsBareMetal bool
294+
DefaultNetworkCardIndex int
286295
}
287296

288297
// PrimaryIPv4Address returns the primary IPv4 address of this node
@@ -1410,15 +1419,28 @@ func (cache *EC2InstanceMetadataCache) FetchInstanceTypeLimits() error {
14101419
instanceType := aws.StringValue(info.InstanceType)
14111420
eniLimit := int(aws.Int64Value(info.NetworkInfo.MaximumNetworkInterfaces))
14121421
ipv4Limit := int(aws.Int64Value(info.NetworkInfo.Ipv4AddressesPerInterface))
1413-
hypervisorType := aws.StringValue(info.Hypervisor)
14141422
isBareMetalInstance := aws.BoolValue(info.BareMetal)
1423+
hypervisorType := aws.StringValue(info.Hypervisor)
1424+
if hypervisorType == "" {
1425+
hypervisorType = "unknown"
1426+
}
1427+
networkCards := make([]NetworkCard, aws.Int64Value(info.NetworkInfo.MaximumNetworkCards))
1428+
defaultNetworkCardIndex := int(aws.Int64Value(info.NetworkInfo.DefaultNetworkCardIndex))
1429+
for idx := 0; idx < len(networkCards); idx += 1 {
1430+
networkCards[idx] = NetworkCard{
1431+
MaximumNetworkInterfaces: *info.NetworkInfo.NetworkCards[idx].MaximumNetworkInterfaces,
1432+
NetworkCardIndex: *info.NetworkInfo.NetworkCards[idx].NetworkCardIndex,
1433+
}
1434+
}
14151435
//Not checking for empty hypervisorType since have seen certain instances not getting this filled.
14161436
if instanceType != "" && eniLimit > 0 && ipv4Limit > 0 {
14171437
eniLimits = InstanceTypeLimits{
1418-
ENILimit: eniLimit,
1419-
IPv4Limit: ipv4Limit,
1420-
HypervisorType: hypervisorType,
1421-
IsBareMetal: isBareMetalInstance,
1438+
ENILimit: eniLimit,
1439+
IPv4Limit: ipv4Limit,
1440+
NetworkCards: networkCards,
1441+
DefaultNetworkCardIndex: defaultNetworkCardIndex,
1442+
HypervisorType: hypervisorType,
1443+
IsBareMetal: isBareMetalInstance,
14221444
}
14231445

14241446
InstanceNetworkingLimits[instanceType] = eniLimits

0 commit comments

Comments
 (0)