Browse code

IPAM allocator to not accept a datastore update if already present

- Restoring the above behavior which got recently broken

Signed-off-by: Alessandro Boch <aboch@docker.com>

Alessandro Boch authored on 2016/05/10 05:36:40
Showing 1 changed files
... ...
@@ -147,9 +147,11 @@ func (a *Allocator) initializeAddressSpace(as string, ds datastore.DataStore) er
147 147
 	}
148 148
 
149 149
 	a.Lock()
150
-	if _, ok := a.addrSpaces[as]; ok {
151
-		a.Unlock()
152
-		return types.ForbiddenErrorf("tried to add an axisting address space: %s", as)
150
+	if currAS, ok := a.addrSpaces[as]; ok {
151
+		if currAS.ds != nil {
152
+			a.Unlock()
153
+			return types.ForbiddenErrorf("a datastore is already configured for the address space %s", as)
154
+		}
153 155
 	}
154 156
 	a.addrSpaces[as] = &addrSpace{
155 157
 		subnets: map[SubnetKey]*PoolData{},