@@ -277,12 +277,21 @@ type ENIMetadata struct {
277
277
IPv6Prefixes []* ec2.Ipv6PrefixSpecification
278
278
}
279
279
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
+
280
287
// InstanceTypeLimits keeps track of limits for an instance type
281
288
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
286
295
}
287
296
288
297
// PrimaryIPv4Address returns the primary IPv4 address of this node
@@ -1410,15 +1419,28 @@ func (cache *EC2InstanceMetadataCache) FetchInstanceTypeLimits() error {
1410
1419
instanceType := aws .StringValue (info .InstanceType )
1411
1420
eniLimit := int (aws .Int64Value (info .NetworkInfo .MaximumNetworkInterfaces ))
1412
1421
ipv4Limit := int (aws .Int64Value (info .NetworkInfo .Ipv4AddressesPerInterface ))
1413
- hypervisorType := aws .StringValue (info .Hypervisor )
1414
1422
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
+ }
1415
1435
//Not checking for empty hypervisorType since have seen certain instances not getting this filled.
1416
1436
if instanceType != "" && eniLimit > 0 && ipv4Limit > 0 {
1417
1437
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 ,
1422
1444
}
1423
1445
1424
1446
InstanceNetworkingLimits [instanceType ] = eniLimits
0 commit comments