瀏覽代碼

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 9 年之前
父節點
當前提交
a9c9765b33
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. 5 3
      libnetwork/ipam/allocator.go

+ 5 - 3
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{},