Skip to content

Commit

Permalink
fix: add max reconcile delay interval to IPAM monitor (#3051)
Browse files Browse the repository at this point in the history
add max reconcile delay interval to IPAM monitor

Signed-off-by: Evan Baker <[email protected]>
  • Loading branch information
rbtr authored Oct 4, 2024
1 parent c6d5b1e commit 7938db8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cns/ipampool/v2/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"math"
"sync"
"time"

"github.com/Azure/azure-container-networking/cns"
"github.com/Azure/azure-container-networking/crd/clustersubnetstate/api/v1alpha1"
Expand Down Expand Up @@ -65,9 +66,10 @@ func NewMonitor(z *zap.Logger, store ipStateStore, nnccli nodeNetworkConfigSpecU

// Start begins the Monitor's pool reconcile loop.
// On first run, it will block until a NodeNetworkConfig is received (through a call to Update()).
// Subsequently, it will run run once per RefreshDelay and attempt to re-reconcile the pool.
// Subsequently, it will run run when Events happen or at least once per ReconcileDelay and attempt to re-reconcile the pool.
func (pm *Monitor) Start(ctx context.Context) error {
pm.z.Debug("starting")
maxReconcileDelay := time.NewTicker(60 * time.Second) //nolint:gomnd // 60 seconds
for {
// proceed when things happen:
select {
Expand All @@ -89,6 +91,7 @@ func (pm *Monitor) Start(ctx context.Context) error {
pm.z.Debug("started", zap.Int64("initial request", pm.request))
})
pm.z.Info("scaler update", zap.Int64("batch", pm.scaler.batch), zap.Float64("buffer", pm.scaler.buffer), zap.Int64("max", pm.scaler.max), zap.Int64("request", pm.request))
case <-maxReconcileDelay.C: // try to reconcile the pool every maxReconcileDelay to prevent drift or lockups.
}
select {
case <-pm.started: // this blocks until we have initialized
Expand Down

0 comments on commit 7938db8

Please sign in to comment.