@@ -94,7 +94,6 @@ func (pm *Monitor) Start(ctx context.Context) error {
9494 continue
9595 }
9696 case nnc := <- pm .nncSource : // received a new NodeNetworkConfig, extract the data from it and re-reconcile.
97- pm .spec = nnc .Spec
9897 scaler := nnc .Status .Scaler
9998
10099 // 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 {
105104 pm .metastate .batch = scaler .BatchSize
106105 pm .metastate .max = scaler .MaxIPCount
107106 pm .metastate .minFreeCount , pm .metastate .maxFreeCount = CalculateMinFreeIPs (scaler ), CalculateMaxFreeIPs (scaler )
108- pm .once .Do (func () { close (pm .started ) }) // close the init channel the first time we receive a NodeNetworkConfig.
107+ pm .once .Do (func () {
108+ pm .spec = nnc .Spec // set the spec from the NNC initially (afterwards we write the Spec so we know target state).
109+ logger .Printf ("[ipam-pool-monitor] set initial pool spec %+v" , pm .spec )
110+ close (pm .started ) // close the init channel the first time we fully receive a NodeNetworkConfig.
111+ })
109112 }
110113 // if control has flowed through the select(s) to this point, we can now reconcile.
111114 err := pm .reconcile (ctx )
@@ -376,6 +379,7 @@ func (pm *Monitor) Update(nnc *v1alpha.NodeNetworkConfig) error {
376379 // observe elapsed duration for IP pool scaling
377380 metric .ObserverPoolScaleLatency ()
378381 }
382+ logger .Printf ("[ipam-pool-monitor] pushing NodeNetworkConfig update, allocatedIPs = %d" , allocatedIPs )
379383 pm .nncSource <- * nnc
380384 return nil
381385}
0 commit comments