Skip to content

Commit 2d55c28

Browse files
remove synchost skip and single ip skip
1 parent 26be9a4 commit 2d55c28

File tree

3 files changed

+11
-60
lines changed

3 files changed

+11
-60
lines changed

cns/kubecontroller/nodenetworkconfig/conversion_linux.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,12 @@ import (
1616
func createNCRequestFromStaticNCHelper(nc v1alpha.NetworkContainer, primaryIPPrefix netip.Prefix, subnet cns.IPSubnet) (*cns.CreateNetworkContainerRequest, error) {
1717
secondaryIPConfigs := map[string]cns.SecondaryIPConfig{}
1818

19-
// in the case of vnet prefix on swift v2 the primary IP is a /32 and should not be added to secondary IP configs
20-
if !primaryIPPrefix.IsSingleIP() {
21-
// iterate through all IP addresses in the subnet described by primaryPrefix and
22-
// add them to the request as secondary IPConfigs.
23-
for addr := primaryIPPrefix.Masked().Addr(); primaryIPPrefix.Contains(addr); addr = addr.Next() {
24-
secondaryIPConfigs[addr.String()] = cns.SecondaryIPConfig{
25-
IPAddress: addr.String(),
26-
NCVersion: int(nc.Version),
27-
}
19+
// iterate through all IP addresses in the subnet described by primaryPrefix and
20+
// add them to the request as secondary IPConfigs.
21+
for addr := primaryIPPrefix.Masked().Addr(); primaryIPPrefix.Contains(addr); addr = addr.Next() {
22+
secondaryIPConfigs[addr.String()] = cns.SecondaryIPConfig{
23+
IPAddress: addr.String(),
24+
NCVersion: int(nc.Version),
2825
}
2926
}
3027

cns/restserver/internalapi.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,6 @@ func (service *HTTPRestService) syncHostNCVersion(ctx context.Context, channelMo
191191
outdatedNCs := map[string]struct{}{}
192192
programmedNCs := map[string]struct{}{}
193193
for idx := range service.state.ContainerStatus {
194-
195-
// For prefix-on-NIC SwiftV2 NIC scenario, the NC details is published to different path in NMAgent and call to NMA here creates error. So Skipping nma check, synchost version logic.
196-
ncStatus := service.state.ContainerStatus[idx]
197-
if mac := ncStatus.CreateNetworkContainerRequest.NetworkInterfaceInfo.MACAddress; mac != "" {
198-
logger.Printf("NC %s has MAC address for prefix on nic swiftv2 prefix on NIC scenario, skipping syncHostNCVersion", ncStatus.ID)
199-
continue
200-
}
201194
// Will open a separate PR to convert all the NC version related variable to int. Change from string to int is a pain.
202195
localNCVersion, err := strconv.Atoi(service.state.ContainerStatus[idx].HostVersion)
203196
if err != nil {

cns/restserver/internalapi_test.go

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ const (
4242
batchSize = 10
4343
initPoolSize = 10
4444
ncID = "6a07155a-32d7-49af-872f-1e70ee366dc0"
45-
macAddress = "00:11:22:33:44:55"
4645
)
4746

4847
var dnsservers = []string{"8.8.8.8", "8.8.4.4"}
@@ -313,29 +312,7 @@ func TestPendingIPsGotUpdatedWhenSyncHostNCVersion(t *testing.T) {
313312
}
314313
}
315314

316-
func TestSyncHostNCVersion_SkipsNCVersionForPrefixOnNICSwiftV2(t *testing.T) {
317-
orchestratorTypes := []string{cns.Kubernetes, cns.KubernetesCRD}
318-
for _, orchestratorType := range orchestratorTypes {
319-
t.Run(orchestratorType, func(t *testing.T) {
320-
req := createNCReqeustForSyncHostNCVersion(t, macAddress)
321-
containerStatus := svc.state.ContainerStatus[req.NetworkContainerid]
322-
//// HostVersion -1 and NC Version 0 and should remain unchanged, should not error
323-
svc.SyncHostNCVersion(context.Background(), orchestratorType)
324-
325-
// HostVersion and Version should remain unchanged
326-
assert.Equal(t, "-1", containerStatus.HostVersion)
327-
assert.Equal(t, "0", containerStatus.CreateNetworkContainerRequest.Version)
328-
})
329-
}
330-
}
331-
332-
func createNCReqeustForSyncHostNCVersion(t *testing.T, macAddresses ...string) cns.CreateNetworkContainerRequest {
333-
var macAddress string
334-
if len(macAddresses) > 0 {
335-
macAddress = macAddresses[0]
336-
} else {
337-
macAddress = ""
338-
}
315+
func createNCReqeustForSyncHostNCVersion(t *testing.T) cns.CreateNetworkContainerRequest {
339316
restartService()
340317
setEnv(t)
341318
setOrchestratorTypeInternal(cns.KubernetesCRD)
@@ -349,7 +326,7 @@ func createNCReqeustForSyncHostNCVersion(t *testing.T, macAddresses ...string) c
349326
secIPConfig := newSecondaryIPConfig(ipAddress, ncVersion)
350327
ipID := uuid.New()
351328
secondaryIPConfigs[ipID.String()] = secIPConfig
352-
req := createNCReqInternal(t, secondaryIPConfigs, ncID, strconv.Itoa(ncVersion), macAddress)
329+
req := createNCReqInternal(t, secondaryIPConfigs, ncID, strconv.Itoa(ncVersion))
353330
return req
354331
}
355332

@@ -928,14 +905,7 @@ func validateNetworkRequest(t *testing.T, req cns.CreateNetworkContainerRequest)
928905
}
929906
}
930907

931-
func generateNetworkContainerRequest(secondaryIps map[string]cns.SecondaryIPConfig, ncID, ncVersion string, macAddress ...string) *cns.CreateNetworkContainerRequest {
932-
var mac string
933-
if len(macAddress) > 0 {
934-
mac = macAddress[0]
935-
} else {
936-
mac = ""
937-
}
938-
908+
func generateNetworkContainerRequest(secondaryIps map[string]cns.SecondaryIPConfig, ncID, ncVersion string) *cns.CreateNetworkContainerRequest {
939909
var ipConfig cns.IPConfiguration
940910
ipConfig.DNSServers = dnsservers
941911
ipConfig.GatewayIPAddress = gatewayIP
@@ -949,9 +919,6 @@ func generateNetworkContainerRequest(secondaryIps map[string]cns.SecondaryIPConf
949919
NetworkContainerid: ncID,
950920
IPConfiguration: ipConfig,
951921
Version: ncVersion,
952-
NetworkInterfaceInfo: cns.NetworkInterfaceInfo{
953-
MACAddress: mac,
954-
},
955922
}
956923

957924
ncVersionInInt, _ := strconv.Atoi(ncVersion)
@@ -1078,14 +1045,8 @@ func validateIPAMStateAfterReconcile(t *testing.T, ncReqs []*cns.CreateNetworkCo
10781045
}
10791046
}
10801047

1081-
func createNCReqInternal(t *testing.T, secondaryIPConfigs map[string]cns.SecondaryIPConfig, ncID, ncVersion string, macAddresses ...string) cns.CreateNetworkContainerRequest {
1082-
var macAddress string
1083-
if len(macAddresses) > 0 {
1084-
macAddress = macAddresses[0]
1085-
} else {
1086-
macAddress = ""
1087-
}
1088-
req := generateNetworkContainerRequest(secondaryIPConfigs, ncID, ncVersion, macAddress)
1048+
func createNCReqInternal(t *testing.T, secondaryIPConfigs map[string]cns.SecondaryIPConfig, ncID, ncVersion string) cns.CreateNetworkContainerRequest {
1049+
req := generateNetworkContainerRequest(secondaryIPConfigs, ncID, ncVersion)
10891050
returnCode := svc.CreateOrUpdateNetworkContainerInternal(req)
10901051
if returnCode != 0 {
10911052
t.Fatalf("Failed to createNetworkContainerRequest, req: %+v, err: %d", req, returnCode)

0 commit comments

Comments
 (0)