From da7ac78694ed291d15205e578cf0297582a15e54 Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Tue, 28 Jul 2015 12:59:40 +0000 Subject: [PATCH] Don't try and init the ring if the IP address is not in our range. --- ipam/allocate.go | 2 ++ ipam/allocator.go | 1 - ipam/claim.go | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ipam/allocate.go b/ipam/allocate.go index f85c6579..d4a07964 100644 --- a/ipam/allocate.go +++ b/ipam/allocate.go @@ -35,6 +35,8 @@ func (g *allocate) Try(alloc *Allocator) bool { return true } + alloc.establishRing() + if ok, addr := alloc.space.Allocate(g.r); ok { alloc.debugln("Allocated", addr, "for", g.ident, "in", g.r) alloc.addOwned(g.ident, addr) diff --git a/ipam/allocator.go b/ipam/allocator.go index 36e1a1d8..7900bbcb 100644 --- a/ipam/allocator.go +++ b/ipam/allocator.go @@ -95,7 +95,6 @@ func (alloc *Allocator) doOperation(op operation, ops *[]operation) { op.Cancel() return } - alloc.establishRing() if !op.Try(alloc) { *ops = append(*ops, op) } diff --git a/ipam/claim.go b/ipam/claim.go index aa4ee17b..64b22a02 100644 --- a/ipam/claim.go +++ b/ipam/claim.go @@ -38,6 +38,8 @@ func (c *claim) Try(alloc *Allocator) bool { return true } + alloc.establishRing() + switch owner := alloc.ring.Owner(c.addr); owner { case alloc.ourName: // success