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>
This commit is contained in:
Cory Snider 2023-01-26 13:42:46 -05:00
parent 6f08fe20e9
commit a264f2dc55
2 changed files with 5 additions and 16 deletions

View file

@ -114,12 +114,7 @@ func (a *Allocator) ReleasePool(poolID string) error {
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

View file

@ -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
}
func (aSpace *addrSpace) updatePoolDBOnRemoval(k SubnetKey) (func() error, error) {
func (aSpace *addrSpace) updatePoolDBOnRemoval(k SubnetKey) error {
aSpace.Lock()
defer aSpace.Unlock()
p, ok := aSpace.subnets[k]
if !ok {
return nil, ipamapi.ErrBadPool
return ipamapi.ErrBadPool
}
aSpace.incRefCount(p, -1)
@ -140,20 +140,14 @@ func (aSpace *addrSpace) updatePoolDBOnRemoval(k SubnetKey) (func() error, error
if c.RefCount == 0 {
delete(aSpace.subnets, k)
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
c, ok = aSpace.subnets[k]
}
return func() error { return nil }, nil
return nil
}
func (aSpace *addrSpace) incRefCount(p *PoolData, delta int) {