Skip to content

Commit 8b5e167

Browse files
authored
Accept NNC with no NC as valid and consider pool monitor and reconciler started (#1526)
accept an nnc with no nc as valid and consider monitor and reconciler started Signed-off-by: Evan Baker <[email protected]> Signed-off-by: Evan Baker <[email protected]>
1 parent a19e5fb commit 8b5e167

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

cns/ipampool/monitor.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@ func (pm *Monitor) Start(ctx context.Context) error {
121121
// if we have initialized and enter this case, we proceed out of the select and continue to reconcile.
122122
}
123123
case nnc := <-pm.nncSource: // received a new NodeNetworkConfig, extract the data from it and re-reconcile.
124-
scaler := nnc.Status.Scaler
125-
126-
// Set SubnetName, SubnetAddressSpace and Pod Network ARM ID values to the global subnet, subnetCIDR and subnetARM variables.
127-
subnet = nnc.Status.NetworkContainers[0].SubnetName
128-
subnetCIDR = nnc.Status.NetworkContainers[0].SubnetAddressSpace
129-
subnetARMID = GenerateARMID(&nnc.Status.NetworkContainers[0])
130-
// check for subnet exhaustion
131-
_, pm.metastate.exhausted = exhaustedSubnetSet[nnc.Status.NetworkContainers[0].SubnetName]
124+
if len(nnc.Status.NetworkContainers) > 0 {
125+
// Set SubnetName, SubnetAddressSpace and Pod Network ARM ID values to the global subnet, subnetCIDR and subnetARM variables.
126+
subnet = nnc.Status.NetworkContainers[0].SubnetName
127+
subnetCIDR = nnc.Status.NetworkContainers[0].SubnetAddressSpace
128+
subnetARMID = GenerateARMID(&nnc.Status.NetworkContainers[0])
129+
// check for subnet exhaustion
130+
_, pm.metastate.exhausted = exhaustedSubnetSet[nnc.Status.NetworkContainers[0].SubnetName]
131+
}
132132

133133
pm.metastate.primaryIPAddresses = make(map[string]struct{})
134134
// Add Primary IP to Map, if not present.
@@ -140,6 +140,7 @@ func (pm *Monitor) Start(ctx context.Context) error {
140140
}
141141
}
142142

143+
scaler := nnc.Status.Scaler
143144
pm.metastate.batch = scaler.BatchSize
144145
pm.metastate.max = scaler.MaxIPCount
145146
pm.metastate.minFreeCount, pm.metastate.maxFreeCount = CalculateMinFreeIPs(scaler), CalculateMaxFreeIPs(scaler)
@@ -469,6 +470,7 @@ func (pm *Monitor) clampScaler(scaler *v1alpha.Scaler) {
469470
// CalculateMinFreeIPs calculates the minimum free IP quantity based on the Scaler
470471
// in the passed NodeNetworkConfig.
471472
// Half of odd batches are rounded up!
473+
//
472474
//nolint:gocritic // ignore hugeparam
473475
func CalculateMinFreeIPs(scaler v1alpha.Scaler) int64 {
474476
return int64(float64(scaler.BatchSize)*(float64(scaler.RequestThresholdPercent)/100) + .5) //nolint:gomnd // it's a percent
@@ -477,6 +479,7 @@ func CalculateMinFreeIPs(scaler v1alpha.Scaler) int64 {
477479
// CalculateMaxFreeIPs calculates the maximum free IP quantity based on the Scaler
478480
// in the passed NodeNetworkConfig.
479481
// Half of odd batches are rounded up!
482+
//
480483
//nolint:gocritic // ignore hugeparam
481484
func CalculateMaxFreeIPs(scaler v1alpha.Scaler) int64 {
482485
return int64(float64(scaler.BatchSize)*(float64(scaler.ReleaseThresholdPercent)/100) + .5) //nolint:gomnd // it's a percent

cns/kubecontroller/nodenetworkconfig/reconciler.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (reco
7070

7171
logger.Printf("[cns-rc] CRD Spec: %+v", nnc.Spec)
7272

73-
// if there are no network containers, don't continue to updating Listeners
74-
if len(nnc.Status.NetworkContainers) == 0 {
75-
logger.Errorf("[cns-rc] Empty NetworkContainers")
76-
return reconcile.Result{}, nil
77-
}
78-
7973
ipAssignments := 0
8074
// for each NC, parse it in to a CreateNCRequest and forward it to the appropriate Listener
8175
for i := range nnc.Status.NetworkContainers {

0 commit comments

Comments
 (0)