Skip to content

Commit da9361e

Browse files
authored
Handled PR comments:
* Updated the code to have the NC status be part of the error directly so that it can be consumed by containerD and cx can perform actions on it. * Code update to not use dynamic slices. * Removed the logic which handled 0 IPs allocated to NNC in CNS reconcile Signed-off-by: GitHub <[email protected]>
1 parent 0539aba commit da9361e

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

cns/kubecontroller/nodenetworkconfig/reconciler.go

-8
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,6 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (reco
8686

8787
// for each NC, parse it in to a CreateNCRequest and forward it to the appropriate Listener
8888
for i := range nnc.Status.NetworkContainers {
89-
// if the NC status has not been updated successfully skip the reconcilliation
90-
noIPs := nnc.Status.NetworkContainers[i].IPAssignments == nil || len(nnc.Status.NetworkContainers[i].IPAssignments) == 0
91-
if nnc.Status.NetworkContainers[i].Status != v1alpha.NCUpdateSuccess && noIPs {
92-
logger.Printf("[cns-rc] skipping network container %s found in NNC because NC update status has the error %v",
93-
nnc.Status.NetworkContainers[i].ID, nnc.Status.NetworkContainers[i].Status)
94-
continue
95-
}
96-
9789
// check if this NC matches the Node IP if we have one to check against
9890
if r.nodeIP != "" {
9991
if r.nodeIP != nnc.Status.NetworkContainers[i].NodeIP {

cns/restserver/ipam.go

+7-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/Azure/azure-container-networking/cns/logger"
1515
"github.com/Azure/azure-container-networking/cns/types"
1616
"github.com/Azure/azure-container-networking/common"
17-
"github.com/Azure/azure-container-networking/crd/nodenetworkconfig/api/v1alpha"
1817
"github.com/pkg/errors"
1918
)
2019

@@ -792,9 +791,11 @@ func (service *HTTPRestService) AssignAvailableIPConfigs(podInfo cns.PodInfo) ([
792791
return nil, ErrNoNCs
793792
}
794793
// slice to store NCIDs
795-
ncIDs := make([]string, 0)
796-
for key := range service.state.ContainerStatus {
797-
ncIDs = append(ncIDs, key)
794+
ncIDs := make([]string, numOfNCs)
795+
i := 0
796+
for ncID := range service.state.ContainerStatus {
797+
ncIDs[i] = ncID
798+
i++
798799
}
799800

800801
service.Lock()
@@ -827,10 +828,8 @@ func (service *HTTPRestService) AssignAvailableIPConfigs(podInfo cns.PodInfo) ([
827828
if _, found := ipsToAssign[ncID]; found {
828829
continue
829830
}
830-
if service.state.ContainerStatus[ncID].CreateNetworkContainerRequest.NCStatus == v1alpha.NCStatusSubnetFull {
831-
return podIPInfo, errors.Errorf("not enough IPs available for %s, waiting on Azure CNS to allocate more but the Subnet is full", ncID)
832-
}
833-
return podIPInfo, errors.Errorf("not enough IPs available for %s, waiting on Azure CNS to allocate more", ncID)
831+
return podIPInfo, errors.Errorf("not enough IPs available for %s, waiting on Azure CNS to allocate more with NC Status: %s",
832+
ncID, string(service.state.ContainerStatus[ncID].CreateNetworkContainerRequest.NCStatus))
834833
}
835834
}
836835

0 commit comments

Comments
 (0)