From e42600632f2caed84128d97980093a831020cf72 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 14 Nov 2016 14:51:34 +0000 Subject: [PATCH] Don't release dead container's IP addresses if not asked to check it is alive. --- ipam/allocator.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ipam/allocator.go b/ipam/allocator.go index c0fc0c17..1a846e8b 100644 --- a/ipam/allocator.go +++ b/ipam/allocator.go @@ -322,7 +322,7 @@ func (alloc *Allocator) Claim(ident string, cidr address.CIDR, isContainer, noEr // ContainerDied called from the updater interface. Async. func (alloc *Allocator) ContainerDied(ident string) { alloc.actionChan <- func() { - if alloc.hasOwned(ident) { + if alloc.hasOwnedByContainer(ident) { alloc.debugln("Container", ident, "died; noting to remove later") alloc.dead[ident] = alloc.now() } @@ -335,7 +335,7 @@ func (alloc *Allocator) ContainerDied(ident string) { // ContainerDestroyed called from the updater interface. Async. func (alloc *Allocator) ContainerDestroyed(ident string) { alloc.actionChan <- func() { - if alloc.hasOwned(ident) { + if alloc.hasOwnedByContainer(ident) { alloc.debugln("Container", ident, "destroyed; removing addresses") alloc.delete(ident) delete(alloc.dead, ident) @@ -996,9 +996,9 @@ func (alloc *Allocator) persistOwned() { // Owned addresses -func (alloc *Allocator) hasOwned(ident string) bool { - _, b := alloc.owned[ident] - return b +func (alloc *Allocator) hasOwnedByContainer(ident string) bool { + d, b := alloc.owned[ident] + return b && d.IsContainer } // NB: addr must not be owned by ident already