Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions cns/ipampool/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cns/ipampool/monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestPoolSizeIncrease(t *testing.T) {
releaseThresholdPercent: 150,
requestThresholdPercent: 50,
},
want: 13,
want: 12,
},
{
name: "subnet exhausted",
Expand Down