Remember multiple addresses owned by each container, for multi-subnet use
This commit is contained in:
1 parent
2553850ed4
commit
c7a9dfbb3f
3 files changed
+39
-19
No files matched your search
+12
-3
@@ -24,9 +24,18 @@ func (g *allocate) Try(alloc *Allocator) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// If we have previously stored an address for this container, return it.
|
||||
if addr, found := alloc.owned[g.ident]; found {
|
||||
g.resultChan <- allocateResult{addr, nil}
|
||||
// If we have previously stored an address for this container in this subnet, return it.
|
||||
if addrs, found := alloc.owned[g.ident]; found {
|
||||
for _, addr := range addrs {
|
||||
if g.subnet.Contains(addr) {
|
||||
g.resultChan <- allocateResult{addr, nil}
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !alloc.universe.Overlaps(g.subnet) {
|
||||
g.resultChan <- allocateResult{0, fmt.Errorf("Subnet %s out of bounds: %s", g.subnet, alloc.universe)}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user