Skip to content

Commit a6fc9d8

Browse files
committed
another refactor
1 parent dc56b16 commit a6fc9d8

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

cns/restserver/internalapi_test.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"fmt"
99
"math/rand"
1010
"net"
11-
"net/netip"
1211
"os"
1312
"reflect"
1413
"strconv"
@@ -914,16 +913,6 @@ func generateNetworkContainerRequest(secondaryIps map[string]cns.SecondaryIPConf
914913
ipSubnet.IPAddress = primaryIP
915914
ipSubnet.PrefixLength = subnetPrfixLength
916915
ipConfig.IPSubnet = ipSubnet
917-
ipFamilies := map[cns.IPFamily]struct{}{}
918-
919-
for _, secIPConfig := range secondaryIps {
920-
IP, _ := netip.ParseAddr(secIPConfig.IPAddress)
921-
if IP.Is4() {
922-
ipFamilies[cns.IPv4Family] = struct{}{}
923-
} else {
924-
ipFamilies[cns.IPv6Family] = struct{}{}
925-
}
926-
}
927916

928917
req := cns.CreateNetworkContainerRequest{
929918
NetworkContainerType: dockerContainerType,

cns/restserver/ipam.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ var (
2525
ErrStoreEmpty = errors.New("empty endpoint state store")
2626
ErrParsePodIPFailed = errors.New("failed to parse pod's ip")
2727
ErrNoNCs = errors.New("no NCs found in the CNS internal state")
28-
ErrNoIPFamilies = errors.New("No IP Families found on NCs")
2928
ErrOptManageEndpointState = errors.New("CNS is not set to manage the endpoint state")
3029
ErrEndpointStateNotFound = errors.New("endpoint state could not be found in the statefile")
3130
ErrGetAllNCResponseEmpty = errors.New("failed to get NC responses from statefile")
@@ -1002,6 +1001,10 @@ func (service *HTTPRestService) AssignAvailableIPConfigs(podInfo cns.PodInfo) ([
10021001

10031002
// Gets the IPFamilies from all NCs and store them in a map. This will be used to determine the number of IPs to return
10041003
for ncID := range service.state.ContainerStatus {
1004+
if len(ipFamilies) == 2 {
1005+
break
1006+
}
1007+
10051008
for _, secIPConfig := range service.state.ContainerStatus[ncID].CreateNetworkContainerRequest.SecondaryIPConfigs {
10061009
if len(ipFamilies) == 2 {
10071010
break

0 commit comments

Comments
 (0)