diff --git a/libnetwork/ipam/allocator.go b/libnetwork/ipam/allocator.go index 44811ba89a..119031da89 100644 --- a/libnetwork/ipam/allocator.go +++ b/libnetwork/ipam/allocator.go @@ -130,7 +130,7 @@ func (a *Allocator) RequestPool(addressSpace, pool, subPool string, options map[ log.Debugf("RequestPool(%s, %s, %s, %v, %t)", addressSpace, pool, subPool, options, v6) k, nw, ipr, err := a.parsePoolRequest(addressSpace, pool, subPool, v6) if err != nil { - return "", nil, nil, ipamapi.ErrInvalidPool + return "", nil, nil, types.InternalErrorf("failed to parse pool request for address space %q pool %q subpool %q: %v", addressSpace, pool, subPool, err) } retry: @@ -199,7 +199,7 @@ func (a *Allocator) getAddrSpace(as string) (*addrSpace, error) { defer a.Unlock() aSpace, ok := a.addrSpaces[as] if !ok { - return nil, types.BadRequestErrorf("cannot find locality of address space: %s", as) + return nil, types.BadRequestErrorf("cannot find address space %s (most likey the backing datastore is not configured)", as) } return aSpace, nil } diff --git a/libnetwork/ipam/store.go b/libnetwork/ipam/store.go index f288fca05e..29cd753b60 100644 --- a/libnetwork/ipam/store.go +++ b/libnetwork/ipam/store.go @@ -74,7 +74,11 @@ func (a *Allocator) getStore(as string) datastore.DataStore { a.Lock() defer a.Unlock() - return a.addrSpaces[as].ds + if aSpace, ok := a.addrSpaces[as]; ok { + return aSpace.ds + } + + return nil } func (a *Allocator) getAddressSpaceFromStore(as string) (*addrSpace, error) {