Skip to content

Commit

Permalink
Merge pull request #4561 from spidernet-io/weizhoublue-patch-2
Browse files Browse the repository at this point in the history
optimize the amount  of ip usage
  • Loading branch information
weizhoublue authored Jan 21, 2025
2 parents ba4b57f + 2fe189b commit 3947bf4
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/ippoolmanager/ippool_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ func (im *ipPoolManager) genRandomIP(ctx context.Context, ipPool *spiderpoolv2be
}

// Adding a newly assigned IP
usedIPs = append(usedIPs, resIP)
*ipPool.Status.AllocatedIPCount = int64(len(usedIPs))
*ipPool.Status.AllocatedIPCount = int64(len(usedIPs)) + 1

if *ipPool.Status.AllocatedIPCount > int64(*im.config.MaxAllocatedIPs) {
return nil, fmt.Errorf("%w, threshold of IP records(<=%d) for IPPool %s exceeded", constant.ErrIPUsedOut, im.config.MaxAllocatedIPs, ipPool.Name)
Expand Down

0 comments on commit 3947bf4

Please sign in to comment.