Skip to content

Commit 1bb741a

Browse files
Address PR comments
1 parent e941d99 commit 1bb741a

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

azure-ipam/ipconfig/ipconfig.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"net/netip"
88

99
"github.com/Azure/azure-container-networking/cns"
10-
"github.com/Azure/azure-container-networking/cns/logger"
1110
cniSkel "github.com/containernetworking/cni/pkg/skel"
1211
cniTypes "github.com/containernetworking/cni/pkg/types"
1312
"github.com/pkg/errors"

cns/restserver/internalapi.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func (service *HTTPRestService) syncHostNCVersion(ctx context.Context, channelMo
195195
// 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.
196196
ncStatus := service.state.ContainerStatus[idx]
197197
if mac := ncStatus.CreateNetworkContainerRequest.NetworkInterfaceInfo.MACAddress; mac != "" {
198-
logger.Printf("NC %s has MAC address for prefix on nic swiftv2 scenario, skipping syncHostNCVersion", ncStatus.ID)
198+
logger.Printf("NC %s has MAC address for prefix on nic swiftv2 prefix on NIC scenario, skipping syncHostNCVersion", ncStatus.ID)
199199
continue
200200
}
201201
// Will open a separate PR to convert all the NC version related variable to int. Change from string to int is a pain.
@@ -377,6 +377,7 @@ func (service *HTTPRestService) ReconcileIPAssignment(podInfoByIP map[string]cns
377377
}
378378

379379
func (service *HTTPRestService) CreateNCs(ncReqs []*cns.CreateNetworkContainerRequest) types.ResponseCode {
380+
logger.Printf("Creating network containers for nc requests: [%+v]", ncReqs)
380381
for _, ncReq := range ncReqs {
381382
returnCode := service.CreateOrUpdateNetworkContainerInternal(ncReq)
382383
if returnCode != types.Success {
@@ -566,6 +567,7 @@ func (service *HTTPRestService) MustEnsureNoStaleNCs(validNCIDs []string) {
566567

567568
// This API will be called by CNS RequestController on CRD update.
568569
func (service *HTTPRestService) CreateOrUpdateNetworkContainerInternal(req *cns.CreateNetworkContainerRequest) types.ResponseCode {
570+
logger.Printf("[Azure CNS] CreateOrUpdateNetworkContainerInternal called for network container %s", req.NetworkContainerid)
569571
if req.NetworkContainerid == "" {
570572
logger.Errorf("[Azure CNS] Error. NetworkContainerid is empty")
571573
return types.NetworkContainerNotSpecified
@@ -627,8 +629,9 @@ func (service *HTTPRestService) CreateOrUpdateNetworkContainerInternal(req *cns.
627629
} else {
628630
logger.Errorf(returnMessage)
629631
}
630-
632+
logger.Printf(("service.Options[common.OptProgramSNATIPTables]: %v"), service.Options[common.OptProgramSNATIPTables])
631633
if service.Options[common.OptProgramSNATIPTables] == true {
634+
logger.Printf("inside if block")
632635
returnCode, returnMessage = service.programSNATRules(req)
633636
if returnCode != 0 {
634637
logger.Errorf(returnMessage)

cns/restserver/ipam.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"net"
1010
"net/http"
11+
"net/netip"
1112
"strconv"
1213
"strings"
1314

@@ -1009,14 +1010,14 @@ func (service *HTTPRestService) AssignAvailableIPConfigs(podInfo cns.PodInfo) ([
10091010
break
10101011
}
10111012

1012-
ip := net.ParseIP(secIPConfig.IPAddress)
1013-
if ip == nil {
1013+
addr, err := netip.ParseAddr(secIPConfig.IPAddress)
1014+
if err != nil {
10141015
continue
10151016
}
10161017

1017-
if ip.To4() != nil {
1018+
if addr.Is4() {
10181019
ncIPFamilies[cns.IPv4] = struct{}{}
1019-
} else {
1020+
} else if addr.Is6() {
10201021
ncIPFamilies[cns.IPv6] = struct{}{}
10211022
}
10221023
}

0 commit comments

Comments
 (0)