Skip to content

Commit

Permalink
fix: sometimes alloc ipv6 address failed sometimes ipam.GetStaticAdd…
Browse files Browse the repository at this point in the history
…ress return NoAvailableAddress

 when use ipam.GetStaticAddress with param ipv6 address without clean Zero
 such as "fd00::00e9:0ed1", and exactly subnet.V6FreeIPList has a range
 with start fd00::e9:ed1 and end with any v6 address,or start with an any v6
 address and end with fd00::e9:ed1, it will cause ipr.Start.Equal(ip)
 or ipr.End.Equal(ip) failed, and no v6 address allocated
  • Loading branch information
changluyi committed Dec 7, 2022
1 parent 7d6a162 commit b46b103
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/ipam/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ func (subnet *Subnet) GetStaticAddress(podName string, ip IP, mac string, force
if v4 && !subnet.V4CIDR.Contains(net.ParseIP(string(ip))) {
return ip, mac, OutOfRangeError
}

if v6 {
ip = IP(net.ParseIP(string(ip)).String())
}

if v6 && !subnet.V6CIDR.Contains(net.ParseIP(string(ip))) {
return ip, mac, OutOfRangeError
}
Expand Down

0 comments on commit b46b103

Please sign in to comment.