Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/cfn/builder/network_interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ func buildNetworkInterfaces(
var numEFAs = math.MaxFloat64
for _, it := range info.InstanceTypes {
networkInfo := it.NetworkInfo
numEFAs = math.Min(float64(aws.ToInt32(networkInfo.MaximumNetworkCards)), numEFAs)
if !aws.ToBool(networkInfo.EfaSupported) {
return fmt.Errorf("instance type %s does not support EFA", it.InstanceType)
}
if networkInfo.EfaInfo != nil && networkInfo.EfaInfo.MaximumEfaInterfaces != nil {
numEFAs = math.Min(float64(aws.ToInt32(networkInfo.EfaInfo.MaximumEfaInterfaces)), numEFAs)
} else {
numEFAs = math.Min(float64(aws.ToInt32(networkInfo.MaximumNetworkCards)), numEFAs)
}
}

firstNI.InterfaceType = gfnt.NewString("efa")
Expand Down
44 changes: 44 additions & 0 deletions pkg/cfn/builder/network_interfaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,50 @@ func TestBuildNetworkInterfaces(t *testing.T) {
expectedNetworkInterfaces: 4,
expectedInterfaceType: "efa",
},
{
name: "EFA nodegroup with MaximumEfaInterfaces less than MaximumNetworkCards",
instanceTypes: []string{"p6-b300.48xlarge"},
efaEnabled: true,
securityGroups: []*gfnt.Value{
gfnt.NewString("sg-12345"),
},
mockInstanceTypes: []ec2types.InstanceTypeInfo{
{
InstanceType: "p6-b300.48xlarge",
NetworkInfo: &ec2types.NetworkInfo{
MaximumNetworkCards: aws.Int32(17),
EfaSupported: aws.Bool(true),
EfaInfo: &ec2types.EfaInfo{
MaximumEfaInterfaces: aws.Int32(8),
},
},
},
},
expectedNetworkInterfaces: 8,
expectedInterfaceType: "efa",
},
{
name: "EFA nodegroup with EfaInfo present and matching MaximumNetworkCards",
instanceTypes: []string{"p5.48xlarge"},
efaEnabled: true,
securityGroups: []*gfnt.Value{
gfnt.NewString("sg-12345"),
},
mockInstanceTypes: []ec2types.InstanceTypeInfo{
{
InstanceType: "p5.48xlarge",
NetworkInfo: &ec2types.NetworkInfo{
MaximumNetworkCards: aws.Int32(32),
EfaSupported: aws.Bool(true),
EfaInfo: &ec2types.EfaInfo{
MaximumEfaInterfaces: aws.Int32(32),
},
},
},
},
expectedNetworkInterfaces: 32,
expectedInterfaceType: "efa",
},
{
name: "EFA nodegroup with custom EFA security groups (1.32 scenario)",
instanceTypes: []string{"c5n.18xlarge"},
Expand Down