Skip to content

Commit 6e58760

Browse files
Fix max-pods-calculator to consider only network card 0 (#1930)
1 parent 83b2dc6 commit 6e58760

File tree

5 files changed

+106
-8
lines changed

5 files changed

+106
-8
lines changed

templates/al2/runtime/max-pods-calculator.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,16 @@ if [[ "$CNI_MAJOR_VERSION" -gt 1 ]] || ([[ "$CNI_MAJOR_VERSION" = 1 ]] && [[ "$C
116116
PREFIX_DELEGATION_SUPPORTED=true
117117
fi
118118

119-
DESCRIBE_INSTANCES_RESULT=$(aws ec2 describe-instance-types --instance-type "${INSTANCE_TYPE}" --query 'InstanceTypes[0].{Hypervisor: Hypervisor, EniCount: NetworkInfo.MaximumNetworkInterfaces, PodsPerEniCount: NetworkInfo.Ipv4AddressesPerInterface, CpuCount: VCpuInfo.DefaultVCpus}' --output json)
120-
119+
DESCRIBE_INSTANCES_RESULT=$(aws ec2 describe-instance-types --instance-type "${INSTANCE_TYPE}" --query 'InstanceTypes[0].{Hypervisor: Hypervisor, NetworkInfo: NetworkInfo, CpuCount: VCpuInfo.DefaultVCpus}' --output json)
121120
HYPERVISOR_TYPE=$(echo $DESCRIBE_INSTANCES_RESULT | jq -r '.Hypervisor')
122121
IS_NITRO=false
123122
if [[ "$HYPERVISOR_TYPE" == "nitro" ]]; then
124123
IS_NITRO=true
125124
fi
126-
INSTANCE_MAX_ENIS=$(echo $DESCRIBE_INSTANCES_RESULT | jq -r '.EniCount')
127-
INSTANCE_MAX_ENIS_IPS=$(echo $DESCRIBE_INSTANCES_RESULT | jq -r '.PodsPerEniCount')
125+
# Only one network card is used for pods, the default network card which is usually the network card 0
126+
DEFAULT_NETWORK_CARD_INDEX=$(echo $DESCRIBE_INSTANCES_RESULT | jq -r '.NetworkInfo.DefaultNetworkCardIndex')
127+
INSTANCE_MAX_ENIS=$(echo $DESCRIBE_INSTANCES_RESULT | jq -r ".NetworkInfo.NetworkCards[$DEFAULT_NETWORK_CARD_INDEX].MaximumNetworkInterfaces")
128+
INSTANCE_MAX_ENIS_IPS=$(echo $DESCRIBE_INSTANCES_RESULT | jq -r '.NetworkInfo.Ipv4AddressesPerInterface')
128129

129130
if [ -z "$CNI_MAX_ENI" ]; then
130131
enis_for_pods=$INSTANCE_MAX_ENIS
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
echo "-> Should calc max-pods successfully for c6in.32xlarge VPC CNI 1.18.0"
5+
exit_code=0
6+
out=$(/etc/eks/max-pods-calculator.sh \
7+
--instance-type c6in.32xlarge \
8+
--cni-version 1.18.0 \
9+
--show-max-allowed || exit_code=$?)
10+
echo $out
11+
12+
if [[ ${exit_code} -ne 0 ]]; then
13+
echo "❌ Test Failed: expected a non-zero exit code but got '${exit_code}'"
14+
exit 1
15+
fi
16+
expected_max_pods="394"
17+
actual_max_pods=$(grep -o '[0-9]\+' <<< ${out})
18+
if [[ ${actual_max_pods} -ne ${expected_max_pods} ]]; then
19+
echo "❌ Test Failed: expected max-pods for c6in.32xlarge w/ CNI 1.18.5 to be '${expected_max_pods}', but got '${actual_max_pods}'"
20+
exit 1
21+
fi
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"Hypervisor": "nitro",
3+
"NetworkInfo": {
4+
"NetworkPerformance": "200 Gigabit",
5+
"MaximumNetworkInterfaces": 16,
6+
"MaximumNetworkCards": 2,
7+
"DefaultNetworkCardIndex": 0,
8+
"NetworkCards": [
9+
{
10+
"NetworkCardIndex": 0,
11+
"NetworkPerformance": "Up to 170 Gigabit",
12+
"MaximumNetworkInterfaces": 8,
13+
"BaselineBandwidthInGbps": 200.0,
14+
"PeakBandwidthInGbps": 200.0
15+
},
16+
{
17+
"NetworkCardIndex": 1,
18+
"NetworkPerformance": "Up to 170 Gigabit",
19+
"MaximumNetworkInterfaces": 8,
20+
"BaselineBandwidthInGbps": 200.0,
21+
"PeakBandwidthInGbps": 200.0
22+
}
23+
],
24+
"Ipv4AddressesPerInterface": 50,
25+
"Ipv6AddressesPerInterface": 50,
26+
"Ipv6Supported": true,
27+
"EnaSupport": "required",
28+
"EfaSupported": true,
29+
"EfaInfo": {
30+
"MaximumEfaInterfaces": 2
31+
},
32+
"EncryptionInTransitSupported": true,
33+
"EnaSrdSupported": false
34+
},
35+
"CpuCount": 128
36+
}
Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
{
22
"Hypervisor": "xen",
3-
"EniCount": 4,
4-
"PodsPerEniCount": 15,
3+
"NetworkInfo": {
4+
"NetworkPerformance": "High",
5+
"MaximumNetworkInterfaces": 4,
6+
"MaximumNetworkCards": 1,
7+
"DefaultNetworkCardIndex": 0,
8+
"NetworkCards": [
9+
{
10+
"NetworkCardIndex": 0,
11+
"NetworkPerformance": "High",
12+
"MaximumNetworkInterfaces": 4,
13+
"BaselineBandwidthInGbps": 0.75,
14+
"PeakBandwidthInGbps": 2.8
15+
}
16+
],
17+
"Ipv4AddressesPerInterface": 15,
18+
"Ipv6AddressesPerInterface": 15,
19+
"Ipv6Supported": true,
20+
"EnaSupport": "unsupported",
21+
"EfaSupported": false,
22+
"EncryptionInTransitSupported": false,
23+
"EnaSrdSupported": false
24+
},
525
"CpuCount": 4
626
}
Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
{
22
"Hypervisor": "nitro",
3-
"EniCount": 8,
4-
"PodsPerEniCount": 30,
3+
"NetworkInfo": {
4+
"NetworkPerformance": "10 Gigabit",
5+
"MaximumNetworkInterfaces": 8,
6+
"MaximumNetworkCards": 1,
7+
"DefaultNetworkCardIndex": 0,
8+
"NetworkCards": [
9+
{
10+
"NetworkCardIndex": 0,
11+
"NetworkPerformance": "10 Gigabit",
12+
"MaximumNetworkInterfaces": 8,
13+
"BaselineBandwidthInGbps": 10.0,
14+
"PeakBandwidthInGbps": 10.0
15+
}
16+
],
17+
"Ipv4AddressesPerInterface": 30,
18+
"Ipv6AddressesPerInterface": 30,
19+
"Ipv6Supported": true,
20+
"EnaSupport": "required",
21+
"EfaSupported": false,
22+
"EncryptionInTransitSupported": false,
23+
"EnaSrdSupported": false
24+
},
525
"CpuCount": 32
626
}

0 commit comments

Comments
 (0)