Skip to content

Commit

Permalink
Fix max eni limit for multicard
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Chen committed Feb 3, 2024
1 parent 9a23696 commit 7e98171
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/vpc/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/vpc/vpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7e98171

Please sign in to comment.