From 6741ca64c383349367361dc47c858309815d4c50 Mon Sep 17 00:00:00 2001 From: Evan Baker Date: Tue, 12 Apr 2022 20:15:10 +0000 Subject: [PATCH] save local target spec in ipampoolmonitor instead of overwriting from NNC Signed-off-by: Evan Baker --- cns/ipampool/monitor.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cns/ipampool/monitor.go b/cns/ipampool/monitor.go index 645a2d8834..dceb3be3e0 100644 --- a/cns/ipampool/monitor.go +++ b/cns/ipampool/monitor.go @@ -94,7 +94,6 @@ func (pm *Monitor) Start(ctx context.Context) error { continue } case nnc := <-pm.nncSource: // received a new NodeNetworkConfig, extract the data from it and re-reconcile. - pm.spec = nnc.Spec scaler := nnc.Status.Scaler // Set SubnetName, SubnetAddressSpace and Pod Network ARM ID values to the global subnet, subnetCIDR and subnetARM variables. @@ -105,7 +104,11 @@ func (pm *Monitor) Start(ctx context.Context) error { pm.metastate.batch = scaler.BatchSize pm.metastate.max = scaler.MaxIPCount pm.metastate.minFreeCount, pm.metastate.maxFreeCount = CalculateMinFreeIPs(scaler), CalculateMaxFreeIPs(scaler) - pm.once.Do(func() { close(pm.started) }) // close the init channel the first time we receive a NodeNetworkConfig. + pm.once.Do(func() { + pm.spec = nnc.Spec // set the spec from the NNC initially (afterwards we write the Spec so we know target state). + logger.Printf("[ipam-pool-monitor] set initial pool spec %+v", pm.spec) + close(pm.started) // close the init channel the first time we fully receive a NodeNetworkConfig. + }) } // if control has flowed through the select(s) to this point, we can now reconcile. err := pm.reconcile(ctx) @@ -376,6 +379,7 @@ func (pm *Monitor) Update(nnc *v1alpha.NodeNetworkConfig) error { // observe elapsed duration for IP pool scaling metric.ObserverPoolScaleLatency() } + logger.Printf("[ipam-pool-monitor] pushing NodeNetworkConfig update, allocatedIPs = %d", allocatedIPs) pm.nncSource <- *nnc return nil }