From a9c9765b3349d9c8f689ce575f024f0e63f425db Mon Sep 17 00:00:00 2001 From: Alessandro Boch Date: Mon, 9 May 2016 13:36:40 -0700 Subject: [PATCH] IPAM allocator to not accept a datastore update if already present - Restoring the above behavior which got recently broken Signed-off-by: Alessandro Boch --- libnetwork/ipam/allocator.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libnetwork/ipam/allocator.go b/libnetwork/ipam/allocator.go index 009ab8b55c..c059d447d7 100644 --- a/libnetwork/ipam/allocator.go +++ b/libnetwork/ipam/allocator.go @@ -147,9 +147,11 @@ func (a *Allocator) initializeAddressSpace(as string, ds datastore.DataStore) er } a.Lock() - if _, ok := a.addrSpaces[as]; ok { - a.Unlock() - return types.ForbiddenErrorf("tried to add an axisting address space: %s", as) + if currAS, ok := a.addrSpaces[as]; ok { + if currAS.ds != nil { + a.Unlock() + return types.ForbiddenErrorf("a datastore is already configured for the address space %s", as) + } } a.addrSpaces[as] = &addrSpace{ subnets: map[SubnetKey]*PoolData{},