Browse Source

libnetwork/ipam: skip Destroy()ing bitseq.Handle values

The (*bitseq.Handle).Destroy() method deletes the persisted KVObject
from the datastore. This is a no-op on all the bitseq handles in package
ipam as they are not persisted in any datastore.

Signed-off-by: Cory Snider <csnider@mirantis.com>
Cory Snider 2 năm trước cách đây
mục cha
commit
a264f2dc55

+ 1 - 6
libnetwork/ipam/allocator.go

@@ -114,12 +114,7 @@ func (a *Allocator) ReleasePool(poolID string) error {
 		return err
 		return err
 	}
 	}
 
 
-	remove, err := aSpace.updatePoolDBOnRemoval(k)
-	if err != nil {
-		return err
-	}
-
-	return remove()
+	return aSpace.updatePoolDBOnRemoval(k)
 }
 }
 
 
 // Given the address space, returns the local or global PoolConfig based on whether the
 // Given the address space, returns the local or global PoolConfig based on whether the

+ 4 - 10
libnetwork/ipam/structures.go

@@ -124,13 +124,13 @@ func (aSpace *addrSpace) updatePoolDBOnAdd(k SubnetKey, nw *net.IPNet, ipr *Addr
 	return func() error { return aSpace.alloc.insertBitMask(p.ParentKey, nw) }, nil
 	return func() error { return aSpace.alloc.insertBitMask(p.ParentKey, nw) }, nil
 }
 }
 
 
-func (aSpace *addrSpace) updatePoolDBOnRemoval(k SubnetKey) (func() error, error) {
+func (aSpace *addrSpace) updatePoolDBOnRemoval(k SubnetKey) error {
 	aSpace.Lock()
 	aSpace.Lock()
 	defer aSpace.Unlock()
 	defer aSpace.Unlock()
 
 
 	p, ok := aSpace.subnets[k]
 	p, ok := aSpace.subnets[k]
 	if !ok {
 	if !ok {
-		return nil, ipamapi.ErrBadPool
+		return ipamapi.ErrBadPool
 	}
 	}
 
 
 	aSpace.incRefCount(p, -1)
 	aSpace.incRefCount(p, -1)
@@ -140,20 +140,14 @@ func (aSpace *addrSpace) updatePoolDBOnRemoval(k SubnetKey) (func() error, error
 		if c.RefCount == 0 {
 		if c.RefCount == 0 {
 			delete(aSpace.subnets, k)
 			delete(aSpace.subnets, k)
 			if c.Range == nil {
 			if c.Range == nil {
-				return func() error {
-					bm, err := aSpace.alloc.retrieveBitmask(k, c.Pool)
-					if err != nil {
-						return types.InternalErrorf("could not find bitmask in datastore for pool %s removal: %v", k.String(), err)
-					}
-					return bm.Destroy()
-				}, nil
+				return nil
 			}
 			}
 		}
 		}
 		k = c.ParentKey
 		k = c.ParentKey
 		c, ok = aSpace.subnets[k]
 		c, ok = aSpace.subnets[k]
 	}
 	}
 
 
-	return func() error { return nil }, nil
+	return nil
 }
 }
 
 
 func (aSpace *addrSpace) incRefCount(p *PoolData, delta int) {
 func (aSpace *addrSpace) incRefCount(p *PoolData, delta int) {