mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
ipam must honor preferedIP ahead of random allocation from subPool
Currently the default ipam implementation ignores the prefered ip if the request is made on an existing sub-pool. The priority should be other way around. Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
parent
5f21cf3df1
commit
782d9a4618
1 changed files with 4 additions and 4 deletions
|
@ -425,16 +425,16 @@ func (a *Allocator) getAddress(nw *net.IPNet, bitmask *bitseq.Handle, prefAddres
|
|||
}
|
||||
if ipr == nil && prefAddress == nil {
|
||||
ordinal, err = bitmask.SetAny()
|
||||
} else if ipr != nil {
|
||||
base.IP = ipr.Sub.IP
|
||||
ordinal, err = bitmask.SetAnyInRange(ipr.Start, ipr.End)
|
||||
} else {
|
||||
} else if prefAddress != nil {
|
||||
hostPart, e := types.GetHostPartIP(prefAddress, base.Mask)
|
||||
if e != nil {
|
||||
return nil, fmt.Errorf("failed to allocate preferred address %s: %v", prefAddress.String(), e)
|
||||
}
|
||||
ordinal = ipToUint32(types.GetMinimalIP(hostPart))
|
||||
err = bitmask.Set(ordinal)
|
||||
} else {
|
||||
base.IP = ipr.Sub.IP
|
||||
ordinal, err = bitmask.SetAnyInRange(ipr.Start, ipr.End)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, ipamapi.ErrNoAvailableIPs
|
||||
|
|
Loading…
Add table
Reference in a new issue