Skip to content

Commit

Permalink
fix: avoid selecting subnets with insufficient available IP addresses
Browse files Browse the repository at this point in the history
Signed-off-by: Vacant2333 <vacant2333@gmail.com>
  • Loading branch information
Vacant2333 committed Nov 26, 2024
1 parent 5a9af7c commit d120906
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/providers/subnet/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ func (p *DefaultProvider) ZonalSubnetsForLaunch(ctx context.Context, nodeClass *
if trackedIPs, ok := p.inflightIPs[subnet.ID]; ok {
prevIPs = trackedIPs
}

// Check if the remaining IP count is insufficient to meet the predicted IP usage;
// if so, remove this subnet zone record from inflightIPs and continue to the next item in the loop。
if prevIPs-predictedIPsUsed < 0 {
delete(zonalSubnets, subnet.Zone)
continue
}
p.inflightIPs[subnet.ID] = prevIPs - predictedIPsUsed
}
return zonalSubnets, nil
Expand Down

0 comments on commit d120906

Please # to comment.