mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
IPAM to run consistency check over its bitmasks
Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
parent
854fe82ba1
commit
21219731d3
2 changed files with 24 additions and 0 deletions
2
libnetwork/.gitignore
vendored
2
libnetwork/.gitignore
vendored
|
@ -8,6 +8,8 @@ bin/
|
|||
integration-tmp/
|
||||
_obj
|
||||
_test
|
||||
.vagrant
|
||||
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
|
|
|
@ -70,6 +70,9 @@ func NewAllocator(lcDs, glDs datastore.DataStore) (*Allocator, error) {
|
|||
}
|
||||
}
|
||||
|
||||
a.checkConsistency(localAddressSpace)
|
||||
a.checkConsistency(globalAddressSpace)
|
||||
|
||||
return a, nil
|
||||
}
|
||||
|
||||
|
@ -115,6 +118,25 @@ func (a *Allocator) updateBitMasks(aSpace *addrSpace) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Checks for and fixes damaged bitmask. Meant to be called in constructor only.
|
||||
func (a *Allocator) checkConsistency(as string) {
|
||||
// Retrieve this address space's configuration and bitmasks from the datastore
|
||||
a.refresh(as)
|
||||
aSpace, ok := a.addrSpaces[as]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
a.updateBitMasks(aSpace)
|
||||
for sk, pd := range aSpace.subnets {
|
||||
if pd.Range != nil {
|
||||
continue
|
||||
}
|
||||
if err := a.addresses[sk].CheckConsistency(); err != nil {
|
||||
log.Warnf("Error while running consistency check for %s: %v", sk, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GetDefaultAddressSpaces returns the local and global default address spaces
|
||||
func (a *Allocator) GetDefaultAddressSpaces() (string, string, error) {
|
||||
return localAddressSpace, globalAddressSpace, nil
|
||||
|
|
Loading…
Add table
Reference in a new issue