@@ -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
473475func 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
481484func CalculateMaxFreeIPs (scaler v1alpha.Scaler ) int64 {
482485 return int64 (float64 (scaler .BatchSize )* (float64 (scaler .ReleaseThresholdPercent )/ 100 ) + .5 ) //nolint:gomnd // it's a percent
0 commit comments