From 349bd9220fd2b07db6fc9cc71ddd484069df94a9 Mon Sep 17 00:00:00 2001 From: Evan Baker Date: Thu, 8 Sep 2022 23:56:03 +0000 Subject: [PATCH] align pool to batch during scale up Signed-off-by: Evan Baker --- cns/ipampool/monitor.go | 7 +++++-- cns/ipampool/monitor_test.go | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cns/ipampool/monitor.go b/cns/ipampool/monitor.go index 0344128a3d..518afee2fd 100644 --- a/cns/ipampool/monitor.go +++ b/cns/ipampool/monitor.go @@ -261,8 +261,12 @@ func (pm *Monitor) increasePoolSize(ctx context.Context, meta metaState, state i // Query the max IP count previouslyRequestedIPCount := tempNNCSpec.RequestedIPCount batchSize := meta.batch + modResult := previouslyRequestedIPCount % batchSize + logger.Printf("[ipam-pool-monitor] Previously RequestedIP Count %d", previouslyRequestedIPCount) + logger.Printf("[ipam-pool-monitor] Batch size : %d", batchSize) + logger.Printf("[ipam-pool-monitor] modResult of (previously requested IP count mod batch size) = %d", modResult) - tempNNCSpec.RequestedIPCount += batchSize + tempNNCSpec.RequestedIPCount += batchSize - modResult if tempNNCSpec.RequestedIPCount > meta.max { // We don't want to ask for more ips than the max logger.Printf("[ipam-pool-monitor] Requested IP count (%d) is over max limit (%d), requesting max limit instead.", tempNNCSpec.RequestedIPCount, meta.max) @@ -300,7 +304,6 @@ func (pm *Monitor) decreasePoolSize(ctx context.Context, meta metaState, state i previouslyRequestedIPCount := pm.spec.RequestedIPCount batchSize := meta.batch modResult := previouslyRequestedIPCount % batchSize - logger.Printf("[ipam-pool-monitor] Previously RequestedIP Count %d", previouslyRequestedIPCount) logger.Printf("[ipam-pool-monitor] Batch size : %d", batchSize) logger.Printf("[ipam-pool-monitor] modResult of (previously requested IP count mod batch size) = %d", modResult) diff --git a/cns/ipampool/monitor_test.go b/cns/ipampool/monitor_test.go index b0b7b21ad2..0980631d5e 100644 --- a/cns/ipampool/monitor_test.go +++ b/cns/ipampool/monitor_test.go @@ -107,7 +107,7 @@ func TestPoolSizeIncrease(t *testing.T) { releaseThresholdPercent: 150, requestThresholdPercent: 50, }, - want: 13, + want: 12, }, { name: "subnet exhausted",