Skip to content

Commit 7938db8

Browse files
authored
fix: add max reconcile delay interval to IPAM monitor (#3051)
add max reconcile delay interval to IPAM monitor Signed-off-by: Evan Baker <[email protected]>
1 parent c6d5b1e commit 7938db8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cns/ipampool/v2/monitor.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"math"
66
"sync"
7+
"time"
78

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

6667
// Start begins the Monitor's pool reconcile loop.
6768
// On first run, it will block until a NodeNetworkConfig is received (through a call to Update()).
68-
// Subsequently, it will run run once per RefreshDelay and attempt to re-reconcile the pool.
69+
// Subsequently, it will run run when Events happen or at least once per ReconcileDelay and attempt to re-reconcile the pool.
6970
func (pm *Monitor) Start(ctx context.Context) error {
7071
pm.z.Debug("starting")
72+
maxReconcileDelay := time.NewTicker(60 * time.Second) //nolint:gomnd // 60 seconds
7173
for {
7274
// proceed when things happen:
7375
select {
@@ -89,6 +91,7 @@ func (pm *Monitor) Start(ctx context.Context) error {
8991
pm.z.Debug("started", zap.Int64("initial request", pm.request))
9092
})
9193
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))
94+
case <-maxReconcileDelay.C: // try to reconcile the pool every maxReconcileDelay to prevent drift or lockups.
9295
}
9396
select {
9497
case <-pm.started: // this blocks until we have initialized

0 commit comments

Comments
 (0)