diff --git a/pkg/awsutils/awsutils.go b/pkg/awsutils/awsutils.go index 5e027f73d3..94d3d86e6b 100644 --- a/pkg/awsutils/awsutils.go +++ b/pkg/awsutils/awsutils.go @@ -141,6 +141,9 @@ type APIs interface { // GetENILimit returns the number of ENIs that can be attached to an instance GetENILimit() int + // GetNetworkCards returns the network cards the instance has + GetNetworkCards() []vpc.NetworkCard + // GetPrimaryENImac returns the mac address of the primary ENI GetPrimaryENImac() string @@ -153,11 +156,11 @@ type APIs interface { // WaitForENIAndIPsAttached waits until the ENI has been attached and the secondary IPs have been added WaitForENIAndIPsAttached(eni string, wantedSecondaryIPs int) (ENIMetadata, error) - //SetCNIunmanaged ENI - SetCNIUnmanagedENIs(eniID []string) error + //SetMultiCardENIs ENI + SetMultiCardENIs(eniID []string) error - //IsCNIUnmanagedENI - IsCNIUnmanagedENI(eniID string) bool + //IsMultiCardENI + IsMultiCardENI(eniID string) bool //IsPrimaryENI IsPrimaryENI(eniID string) bool @@ -703,13 +706,16 @@ func (cache *EC2InstanceMetadataCache) awsGetFreeDeviceNumber() (int, error) { inst := result.Reservations[0].Instances[0] var device [maxENIs]bool for _, eni := range inst.NetworkInterfaces { - if aws.Int64Value(eni.Attachment.DeviceIndex) > maxENIs { - log.Warnf("The Device Index %d of the attached ENI %s > instance max slot %d", - aws.Int64Value(eni.Attachment.DeviceIndex), aws.StringValue(eni.NetworkInterfaceId), - maxENIs) - } else { - log.Debugf("Discovered device number is used: %d", aws.Int64Value(eni.Attachment.DeviceIndex)) - device[aws.Int64Value(eni.Attachment.DeviceIndex)] = true + // We don't support multi-card yet, so only account for network card zero + if aws.Int64Value(eni.Attachment.NetworkCardIndex) == 0 { + if aws.Int64Value(eni.Attachment.DeviceIndex) > maxENIs { + log.Warnf("The Device Index %d of the attached ENI %s > instance max slot %d", + aws.Int64Value(eni.Attachment.DeviceIndex), aws.StringValue(eni.NetworkInterfaceId), + maxENIs) + } else { + log.Debugf("Discovered device number is used: %d", aws.Int64Value(eni.Attachment.DeviceIndex)) + device[aws.Int64Value(eni.Attachment.DeviceIndex)] = true + } } } @@ -780,6 +786,7 @@ func (cache *EC2InstanceMetadataCache) attachENI(eniID string) (string, error) { DeviceIndex: aws.Int64(int64(freeDevice)), InstanceId: aws.String(cache.instanceID), NetworkInterfaceId: aws.String(eniID), + NetworkCardIndex: aws.Int64(0), } start := time.Now() attachOutput, err := cache.ec2SVC.AttachNetworkInterfaceWithContext(context.Background(), attachInput) @@ -1447,6 +1454,15 @@ func (cache *EC2InstanceMetadataCache) GetENILimit() int { return eniLimit } +// GetNetworkCards returns the network cards the instance has +func (cache *EC2InstanceMetadataCache) GetNetworkCards() []vpc.NetworkCard { + networkCards, err := vpc.GetNetworkCards(cache.instanceType) + if err != nil { + return nil + } + return networkCards +} + // GetInstanceHypervisorFamily returns hypervisor of EC2 instance type func (cache *EC2InstanceMetadataCache) GetInstanceHypervisorFamily() string { hypervisor, err := vpc.GetHypervisorType(cache.instanceType) @@ -1922,16 +1938,16 @@ func (cache *EC2InstanceMetadataCache) getENIsFromPaginatedDescribeNetworkInterf return innerErr } -// SetCNIUnmanagedENIs Set unmanaged ENI set -func (cache *EC2InstanceMetadataCache) SetCNIUnmanagedENIs(eniID []string) error { +// SetMultiCardENIs Set unmanaged ENI set +func (cache *EC2InstanceMetadataCache) SetMultiCardENIs(eniID []string) error { if len(eniID) != 0 { cache.cniunmanagedENIs.Set(eniID) } return nil } -// IsCNIUnmanagedENI returns if the eni is unmanaged -func (cache *EC2InstanceMetadataCache) IsCNIUnmanagedENI(eniID string) bool { +// IsMultiCardENI returns if the eni is unmanaged +func (cache *EC2InstanceMetadataCache) IsMultiCardENI(eniID string) bool { if len(eniID) != 0 { return cache.cniunmanagedENIs.Has(eniID) } diff --git a/pkg/awsutils/awsutils_test.go b/pkg/awsutils/awsutils_test.go index a1f3719cbd..3120c7f628 100644 --- a/pkg/awsutils/awsutils_test.go +++ b/pkg/awsutils/awsutils_test.go @@ -252,7 +252,7 @@ func TestAWSGetFreeDeviceNumberNoDevice(t *testing.T) { for i := 0; i < maxENIs; i++ { var deviceNums [maxENIs]int64 deviceNums[i] = int64(i) - ec2ENI := &ec2.InstanceNetworkInterface{Attachment: &ec2.InstanceNetworkInterfaceAttachment{DeviceIndex: &deviceNums[i]}} + ec2ENI := &ec2.InstanceNetworkInterface{Attachment: &ec2.InstanceNetworkInterfaceAttachment{DeviceIndex: &deviceNums[i], NetworkCardIndex: aws.Int64(0)}} ec2ENIs = append(ec2ENIs, ec2ENI) } result := &ec2.DescribeInstancesOutput{ @@ -426,7 +426,7 @@ func TestAllocENINoFreeDevice(t *testing.T) { for i := 0; i < maxENIs; i++ { var deviceNums [maxENIs]int64 deviceNums[i] = int64(i) - ec2ENI := &ec2.InstanceNetworkInterface{Attachment: &ec2.InstanceNetworkInterfaceAttachment{DeviceIndex: &deviceNums[i]}} + ec2ENI := &ec2.InstanceNetworkInterface{Attachment: &ec2.InstanceNetworkInterfaceAttachment{DeviceIndex: &deviceNums[i], NetworkCardIndex: aws.Int64(0)}} ec2ENIs = append(ec2ENIs, ec2ENI) } result := &ec2.DescribeInstancesOutput{ diff --git a/pkg/awsutils/mocks/awsutils_mocks.go b/pkg/awsutils/mocks/awsutils_mocks.go index b59e281996..54c7ec72c5 100644 --- a/pkg/awsutils/mocks/awsutils_mocks.go +++ b/pkg/awsutils/mocks/awsutils_mocks.go @@ -23,6 +23,7 @@ import ( reflect "reflect" awsutils "github.com/aws/amazon-vpc-cni-k8s/pkg/awsutils" + vpc "github.com/aws/amazon-vpc-cni-k8s/pkg/vpc" ec2 "github.com/aws/aws-sdk-go/service/ec2" gomock "github.com/golang/mock/gomock" ) @@ -324,6 +325,20 @@ func (mr *MockAPIsMockRecorder) GetLocalIPv4() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLocalIPv4", reflect.TypeOf((*MockAPIs)(nil).GetLocalIPv4)) } +// GetNetworkCards mocks base method. +func (m *MockAPIs) GetNetworkCards() []vpc.NetworkCard { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetNetworkCards") + ret0, _ := ret[0].([]vpc.NetworkCard) + return ret0 +} + +// GetNetworkCards indicates an expected call of GetNetworkCards. +func (mr *MockAPIsMockRecorder) GetNetworkCards() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNetworkCards", reflect.TypeOf((*MockAPIs)(nil).GetNetworkCards)) +} + // GetPrimaryENI mocks base method. func (m *MockAPIs) GetPrimaryENI() string { m.ctrl.T.Helper() @@ -394,18 +409,18 @@ func (mr *MockAPIsMockRecorder) InitCachedPrefixDelegation(arg0 interface{}) *go return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InitCachedPrefixDelegation", reflect.TypeOf((*MockAPIs)(nil).InitCachedPrefixDelegation), arg0) } -// IsCNIUnmanagedENI mocks base method. -func (m *MockAPIs) IsCNIUnmanagedENI(arg0 string) bool { +// IsMultiCardENI mocks base method. +func (m *MockAPIs) IsMultiCardENI(arg0 string) bool { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsCNIUnmanagedENI", arg0) + ret := m.ctrl.Call(m, "IsMultiCardENI", arg0) ret0, _ := ret[0].(bool) return ret0 } -// IsCNIUnmanagedENI indicates an expected call of IsCNIUnmanagedENI. -func (mr *MockAPIsMockRecorder) IsCNIUnmanagedENI(arg0 interface{}) *gomock.Call { +// IsMultiCardENI indicates an expected call of IsMultiCardENI. +func (mr *MockAPIsMockRecorder) IsMultiCardENI(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsCNIUnmanagedENI", reflect.TypeOf((*MockAPIs)(nil).IsCNIUnmanagedENI), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsMultiCardENI", reflect.TypeOf((*MockAPIs)(nil).IsMultiCardENI), arg0) } // IsPrefixDelegationSupported mocks base method. @@ -464,18 +479,18 @@ func (mr *MockAPIsMockRecorder) RefreshSGIDs(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RefreshSGIDs", reflect.TypeOf((*MockAPIs)(nil).RefreshSGIDs), arg0) } -// SetCNIUnmanagedENIs mocks base method. -func (m *MockAPIs) SetCNIUnmanagedENIs(arg0 []string) error { +// SetMultiCardENIs mocks base method. +func (m *MockAPIs) SetMultiCardENIs(arg0 []string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetCNIUnmanagedENIs", arg0) + ret := m.ctrl.Call(m, "SetMultiCardENIs", arg0) ret0, _ := ret[0].(error) return ret0 } -// SetCNIUnmanagedENIs indicates an expected call of SetCNIUnmanagedENIs. -func (mr *MockAPIsMockRecorder) SetCNIUnmanagedENIs(arg0 interface{}) *gomock.Call { +// SetMultiCardENIs indicates an expected call of SetMultiCardENIs. +func (mr *MockAPIsMockRecorder) SetMultiCardENIs(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetCNIUnmanagedENIs", reflect.TypeOf((*MockAPIs)(nil).SetCNIUnmanagedENIs), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetMultiCardENIs", reflect.TypeOf((*MockAPIs)(nil).SetMultiCardENIs), arg0) } // SetUnmanagedENIs mocks base method. diff --git a/pkg/ipamd/ipamd.go b/pkg/ipamd/ipamd.go index 6533149900..45c1bff856 100644 --- a/pkg/ipamd/ipamd.go +++ b/pkg/ipamd/ipamd.go @@ -198,13 +198,16 @@ type IPAMContext struct { maxENI int maxPrefixesPerENI int unmanagedENI int - warmENITarget int - warmIPTarget int - minimumIPTarget int - warmPrefixTarget int - primaryIP map[string]string // primaryIP is a map from ENI ID to primary IP of that ENI - lastNodeIPPoolAction time.Time - lastDecreaseIPPool time.Time + numNetworkCards int + multiCardENIs int //ENIs attached to non-zero cards + + warmENITarget int + warmIPTarget int + minimumIPTarget int + warmPrefixTarget int + primaryIP map[string]string // primaryIP is a map from ENI ID to primary IP of that ENI + lastNodeIPPoolAction time.Time + lastDecreaseIPPool time.Time // reconcileCooldownCache keeps timestamps of the last time an IP address was unassigned from an ENI, // so that we don't reconcile and add it back too quickly if IMDS lags behind reality. reconcileCooldownCache ReconcileCooldownCache @@ -346,6 +349,7 @@ func New(k8sClient client.Client) (*IPAMContext, error) { c.enablePodENI = enablePodENI() c.enableManageUntaggedMode = enableManageUntaggedMode() c.enablePodIPAnnotation = enablePodIPAnnotation() + c.numNetworkCards = len(c.awsClient.GetNetworkCards()) err = c.awsClient.FetchInstanceTypeLimits() if err != nil { @@ -408,7 +412,8 @@ func (c *IPAMContext) nodeInit() error { } log.Debugf("DescribeAllENIs success: ENIs: %d, tagged: %d", len(metadataResult.ENIMetadata), len(metadataResult.TagMap)) - c.awsClient.SetCNIUnmanagedENIs(metadataResult.MultiCardENIIDs) + c.awsClient.SetMultiCardENIs(metadataResult.MultiCardENIIDs) + c.multiCardENIs = len(metadataResult.MultiCardENIIDs) c.setUnmanagedENIs(metadataResult.TagMap) enis := c.filterUnmanagedENIs(metadataResult.ENIMetadata) @@ -1359,7 +1364,8 @@ func (c *IPAMContext) nodeIPPoolReconcile(ctx context.Context, interval time.Dur efaENIs = metadataResult.EFAENIs eniTagMap = metadataResult.TagMap c.setUnmanagedENIs(metadataResult.TagMap) - c.awsClient.SetCNIUnmanagedENIs(metadataResult.MultiCardENIIDs) + c.awsClient.SetMultiCardENIs(metadataResult.MultiCardENIIDs) + c.multiCardENIs = len(metadataResult.MultiCardENIIDs) attachedENIs = c.filterUnmanagedENIs(metadataResult.ENIMetadata) } @@ -1768,7 +1774,7 @@ func (c *IPAMContext) filterUnmanagedENIs(enis []awsutils.ENIMetadata) []awsutil log.Debugf("Skipping ENI %s: since it is unmanaged", eni.ENIID) numFiltered++ continue - } else if c.awsClient.IsCNIUnmanagedENI(eni.ENIID) { + } else if c.awsClient.IsMultiCardENI(eni.ENIID) { log.Debugf("Skipping ENI %s: since on non-zero network card", eni.ENIID) numFiltered++ continue @@ -2107,6 +2113,10 @@ func (c *IPAMContext) hasRoomForEni() bool { if c.enablePodENI && c.dataStore.GetTrunkENI() == "" { trunkEni = 1 } + if c.numNetworkCards > 1 { + // For multi-card instances, c.unmanagedENI includes all ENIs attached to non-zero network cards. We must exclude these ENIs from the calculation as they cannot be used. + return c.dataStore.GetENIs() < (c.maxENI - (c.unmanagedENI - c.multiCardENIs) - trunkEni) + } return c.dataStore.GetENIs() < (c.maxENI - c.unmanagedENI - trunkEni) } diff --git a/pkg/ipamd/ipamd_test.go b/pkg/ipamd/ipamd_test.go index 8c360edd42..cc5a27337a 100644 --- a/pkg/ipamd/ipamd_test.go +++ b/pkg/ipamd/ipamd_test.go @@ -144,8 +144,8 @@ func TestNodeInit(t *testing.T) { m.awsutils.EXPECT().IsUnmanagedENI(eni1.ENIID).Return(false).AnyTimes() m.awsutils.EXPECT().IsUnmanagedENI(eni2.ENIID).Return(false).AnyTimes() m.awsutils.EXPECT().TagENI(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() - m.awsutils.EXPECT().IsCNIUnmanagedENI(eni1.ENIID).Return(false).AnyTimes() - m.awsutils.EXPECT().IsCNIUnmanagedENI(eni2.ENIID).Return(false).AnyTimes() + m.awsutils.EXPECT().IsMultiCardENI(eni1.ENIID).Return(false).AnyTimes() + m.awsutils.EXPECT().IsMultiCardENI(eni2.ENIID).Return(false).AnyTimes() primaryIP := net.ParseIP(ipaddr01) m.awsutils.EXPECT().GetVPCIPv4CIDRs().AnyTimes().Return(cidrs, nil) @@ -166,7 +166,7 @@ func TestNodeInit(t *testing.T) { m.awsutils.EXPECT().DescribeAllENIs().Return(resp, nil) m.network.EXPECT().SetupENINetwork(gomock.Any(), secMAC, secDevice, secSubnet) - m.awsutils.EXPECT().SetCNIUnmanagedENIs(resp.MultiCardENIIDs).AnyTimes() + m.awsutils.EXPECT().SetMultiCardENIs(resp.MultiCardENIIDs).AnyTimes() m.awsutils.EXPECT().GetLocalIPv4().Return(primaryIP) var rules []netlink.Rule @@ -234,8 +234,8 @@ func TestNodeInitwithPDenabledIPv4Mode(t *testing.T) { m.awsutils.EXPECT().IsUnmanagedENI(eni1.ENIID).Return(false).AnyTimes() m.awsutils.EXPECT().IsUnmanagedENI(eni2.ENIID).Return(false).AnyTimes() m.awsutils.EXPECT().TagENI(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() - m.awsutils.EXPECT().IsCNIUnmanagedENI(eni1.ENIID).Return(false).AnyTimes() - m.awsutils.EXPECT().IsCNIUnmanagedENI(eni2.ENIID).Return(false).AnyTimes() + m.awsutils.EXPECT().IsMultiCardENI(eni1.ENIID).Return(false).AnyTimes() + m.awsutils.EXPECT().IsMultiCardENI(eni2.ENIID).Return(false).AnyTimes() primaryIP := net.ParseIP(ipaddr01) m.awsutils.EXPECT().GetVPCIPv4CIDRs().AnyTimes().Return(cidrs, nil) @@ -256,7 +256,7 @@ func TestNodeInitwithPDenabledIPv4Mode(t *testing.T) { m.network.EXPECT().SetupENINetwork(gomock.Any(), secMAC, secDevice, secSubnet) m.awsutils.EXPECT().GetLocalIPv4().Return(primaryIP) - m.awsutils.EXPECT().SetCNIUnmanagedENIs(resp.MultiCardENIIDs).AnyTimes() + m.awsutils.EXPECT().SetMultiCardENIs(resp.MultiCardENIIDs).AnyTimes() var rules []netlink.Rule m.network.EXPECT().GetRuleList().Return(rules, nil) @@ -317,7 +317,7 @@ func TestNodeInitwithPDenabledIPv6Mode(t *testing.T) { var cidrs []string m.awsutils.EXPECT().IsUnmanagedENI(eni1.ENIID).Return(false).AnyTimes() m.awsutils.EXPECT().TagENI(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() - m.awsutils.EXPECT().IsCNIUnmanagedENI(eni1.ENIID).Return(false).AnyTimes() + m.awsutils.EXPECT().IsMultiCardENI(eni1.ENIID).Return(false).AnyTimes() primaryIP := net.ParseIP(ipaddr01) m.network.EXPECT().SetupHostNetwork(cidrs, eni1.MAC, &primaryIP, false, false, true).Return(nil) @@ -336,7 +336,7 @@ func TestNodeInitwithPDenabledIPv6Mode(t *testing.T) { } m.awsutils.EXPECT().DescribeAllENIs().Return(resp, nil) m.awsutils.EXPECT().GetLocalIPv4().Return(primaryIP) - m.awsutils.EXPECT().SetCNIUnmanagedENIs(resp.MultiCardENIIDs).AnyTimes() + m.awsutils.EXPECT().SetMultiCardENIs(resp.MultiCardENIIDs).AnyTimes() fakeNode := v1.Node{ TypeMeta: metav1.TypeMeta{Kind: "Node"}, @@ -902,7 +902,7 @@ func TestNodeIPPoolReconcile(t *testing.T) { // Always the primary ENI m.awsutils.EXPECT().GetPrimaryENI().AnyTimes().Return(primaryENIid) m.awsutils.EXPECT().IsUnmanagedENI(primaryENIid).AnyTimes().Return(false) - m.awsutils.EXPECT().IsCNIUnmanagedENI(primaryENIid).AnyTimes().Return(false) + m.awsutils.EXPECT().IsMultiCardENI(primaryENIid).AnyTimes().Return(false) m.awsutils.EXPECT().TagENI(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() eniMetadataList := []awsutils.ENIMetadata{primaryENIMetadata} m.awsutils.EXPECT().GetAttachedENIs().Return(eniMetadataList, nil) @@ -915,7 +915,7 @@ func TestNodeIPPoolReconcile(t *testing.T) { } m.awsutils.EXPECT().DescribeAllENIs().Return(resp, nil) - m.awsutils.EXPECT().SetCNIUnmanagedENIs(resp.MultiCardENIIDs).AnyTimes() + m.awsutils.EXPECT().SetMultiCardENIs(resp.MultiCardENIIDs).AnyTimes() mockContext.nodeIPPoolReconcile(ctx, 0) curENIs := mockContext.dataStore.GetENIInfos() @@ -952,7 +952,7 @@ func TestNodeIPPoolReconcile(t *testing.T) { // Two ENIs found m.awsutils.EXPECT().GetAttachedENIs().Return(twoENIs, nil) m.awsutils.EXPECT().IsUnmanagedENI(secENIid).Times(2).Return(false) - m.awsutils.EXPECT().IsCNIUnmanagedENI(secENIid).Times(2).Return(false) + m.awsutils.EXPECT().IsMultiCardENI(secENIid).Times(2).Return(false) resp2 := awsutils.DescribeAllENIsResult{ ENIMetadata: twoENIs, TagMap: map[string]awsutils.TagMap{}, @@ -962,7 +962,7 @@ func TestNodeIPPoolReconcile(t *testing.T) { } m.awsutils.EXPECT().DescribeAllENIs().Return(resp2, nil) m.network.EXPECT().SetupENINetwork(gomock.Any(), secMAC, secDevice, primarySubnet) - m.awsutils.EXPECT().SetCNIUnmanagedENIs(resp2.MultiCardENIIDs).AnyTimes() + m.awsutils.EXPECT().SetMultiCardENIs(resp2.MultiCardENIIDs).AnyTimes() mockContext.nodeIPPoolReconcile(ctx, 0) @@ -1002,7 +1002,7 @@ func TestNodePrefixPoolReconcile(t *testing.T) { // Always the primary ENI m.awsutils.EXPECT().GetPrimaryENI().AnyTimes().Return(primaryENIid) m.awsutils.EXPECT().IsUnmanagedENI(primaryENIid).AnyTimes().Return(false) - m.awsutils.EXPECT().IsCNIUnmanagedENI(primaryENIid).AnyTimes().Return(false) + m.awsutils.EXPECT().IsMultiCardENI(primaryENIid).AnyTimes().Return(false) m.awsutils.EXPECT().TagENI(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() eniMetadataList := []awsutils.ENIMetadata{primaryENIMetadata} m.awsutils.EXPECT().GetAttachedENIs().Return(eniMetadataList, nil) @@ -1014,7 +1014,7 @@ func TestNodePrefixPoolReconcile(t *testing.T) { } m.awsutils.EXPECT().DescribeAllENIs().Return(resp, nil) - m.awsutils.EXPECT().SetCNIUnmanagedENIs(resp.MultiCardENIIDs).AnyTimes() + m.awsutils.EXPECT().SetMultiCardENIs(resp.MultiCardENIIDs).AnyTimes() mockContext.nodeIPPoolReconcile(ctx, 0) curENIs := mockContext.dataStore.GetENIInfos() @@ -1054,7 +1054,7 @@ func TestNodePrefixPoolReconcile(t *testing.T) { // Two ENIs found m.awsutils.EXPECT().GetAttachedENIs().Return(twoENIs, nil) m.awsutils.EXPECT().IsUnmanagedENI(secENIid).Times(2).Return(false) - m.awsutils.EXPECT().IsCNIUnmanagedENI(secENIid).Times(2).Return(false) + m.awsutils.EXPECT().IsMultiCardENI(secENIid).Times(2).Return(false) resp2 := awsutils.DescribeAllENIsResult{ ENIMetadata: twoENIs, TagMap: map[string]awsutils.TagMap{}, @@ -1063,7 +1063,7 @@ func TestNodePrefixPoolReconcile(t *testing.T) { } m.awsutils.EXPECT().DescribeAllENIs().Return(resp2, nil) m.network.EXPECT().SetupENINetwork(gomock.Any(), secMAC, secDevice, primarySubnet) - m.awsutils.EXPECT().SetCNIUnmanagedENIs(resp2.MultiCardENIIDs).AnyTimes() + m.awsutils.EXPECT().SetMultiCardENIs(resp2.MultiCardENIIDs).AnyTimes() mockContext.nodeIPPoolReconcile(ctx, 0) @@ -1465,7 +1465,7 @@ func TestIPAMContext_filterUnmanagedENIs(t *testing.T) { }).AnyTimes() - mockAWSUtils.EXPECT().IsCNIUnmanagedENI(gomock.Any()).DoAndReturn( + mockAWSUtils.EXPECT().IsMultiCardENI(gomock.Any()).DoAndReturn( func(eni string) (unmanaged bool) { return false @@ -1550,7 +1550,7 @@ func TestIPAMContext_filterUnmanagedENIs_disableManageUntaggedMode(t *testing.T) }).AnyTimes() - mockAWSUtils.EXPECT().IsCNIUnmanagedENI(gomock.Any()).DoAndReturn( + mockAWSUtils.EXPECT().IsMultiCardENI(gomock.Any()).DoAndReturn( func(eni string) (unmanaged bool) { return false @@ -1616,7 +1616,7 @@ func TestNodeIPPoolReconcileBadIMDSData(t *testing.T) { eniMetadataList := []awsutils.ENIMetadata{primaryENIMetadata} m.awsutils.EXPECT().GetAttachedENIs().Return(eniMetadataList, nil) m.awsutils.EXPECT().IsUnmanagedENI(eniID).Return(false).AnyTimes() - m.awsutils.EXPECT().IsCNIUnmanagedENI(eniID).Return(false).AnyTimes() + m.awsutils.EXPECT().IsMultiCardENI(eniID).Return(false).AnyTimes() // First reconcile, IMDS returns correct IPs so no change needed mockContext.nodeIPPoolReconcile(ctx, 0) @@ -1702,7 +1702,7 @@ func TestNodePrefixPoolReconcileBadIMDSData(t *testing.T) { eniMetadataList := []awsutils.ENIMetadata{primaryENIMetadata} m.awsutils.EXPECT().GetAttachedENIs().Return(eniMetadataList, nil) m.awsutils.EXPECT().IsUnmanagedENI(eniID).Return(false).AnyTimes() - m.awsutils.EXPECT().IsCNIUnmanagedENI(eniID).Return(false).AnyTimes() + m.awsutils.EXPECT().IsMultiCardENI(eniID).Return(false).AnyTimes() // First reconcile, IMDS returns correct IPs so no change needed mockContext.nodeIPPoolReconcile(ctx, 0)