From 7e9817106e25803d7a337bd0b0e2d886ec65705c Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Sat, 3 Feb 2024 01:04:04 +0000 Subject: [PATCH] Fix max eni limit for multicard --- pkg/vpc/vpc.go | 7 +++++++ pkg/vpc/vpc_test.go | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/pkg/vpc/vpc.go b/pkg/vpc/vpc.go index 00efbc3ca0..9731b89d21 100644 --- a/pkg/vpc/vpc.go +++ b/pkg/vpc/vpc.go @@ -59,6 +59,13 @@ func GetENILimit(instanceType string) (int, error) { log.Errorf("%s: %s", instanceType, ErrInstanceTypeNotExist) return -1, ErrInstanceTypeNotExist } + if len(instance.NetworkCards) > 1 { + eniLimit := 0 + for _, networkCards := range instance.NetworkCards { + eniLimit = eniLimit + int(networkCards.MaximumNetworkInterfaces) + } + return eniLimit, nil + } return instance.ENILimit, nil } diff --git a/pkg/vpc/vpc_test.go b/pkg/vpc/vpc_test.go index f3cd198995..2d1814f694 100644 --- a/pkg/vpc/vpc_test.go +++ b/pkg/vpc/vpc_test.go @@ -30,6 +30,10 @@ func TestGetENILimit(t *testing.T) { eniLimit, err = GetENILimit("a1.4xlarge") assert.Equal(t, eniLimit, 8) assert.NoError(t, err) + + eniLimit, err = GetENILimit("p5.48xlarge") + assert.Equal(t, eniLimit, 64) + assert.NoError(t, err) } func TestGetIPv4Limit(t *testing.T) {