diff --git a/ipam/allocate.go b/ipam/allocate.go index fbc3a685..c144edfd 100644 --- a/ipam/allocate.go +++ b/ipam/allocate.go @@ -33,7 +33,7 @@ func (g *allocate) Try(alloc *Allocator) bool { return true } - if !alloc.universe.Overlaps(g.r.Range()) { + if !alloc.universe.Range().Overlaps(g.r.Range()) { g.resultChan <- allocateResult{err: fmt.Errorf("range %s out of bounds: %s", g.r, alloc.universe)} return true } diff --git a/ipam/allocator.go b/ipam/allocator.go index 1adec91e..50950ffe 100644 --- a/ipam/allocator.go +++ b/ipam/allocator.go @@ -55,7 +55,7 @@ type Allocator struct { stopChan chan<- struct{} ourName mesh.PeerName seed []mesh.PeerName // optional user supplied ring seed - universe address.Range // superset of all ranges + universe address.CIDR // superset of all ranges ring *ring.Ring // information on ranges owned by all peers space space.Space // more detail on ranges owned by us owned map[string]ownedData // who owns what addresses, indexed by container-ID @@ -80,7 +80,7 @@ type Config struct { OurUID mesh.PeerUID OurNickname string Seed []mesh.PeerName - Universe address.Range + Universe address.CIDR IsObserver bool Quorum func() uint Db db.DB @@ -101,7 +101,7 @@ func NewAllocator(config Config) *Allocator { ourName: config.OurName, seed: config.Seed, universe: config.Universe, - ring: ring.New(config.Universe.Start, config.Universe.End, config.OurName), + ring: ring.New(config.Universe.Range().Start, config.Universe.Range().End, config.OurName), owned: make(map[string]ownedData), db: config.Db, paxos: participant, @@ -953,7 +953,7 @@ func (alloc *Allocator) loadPersistedData() bool { return false } - if persistedRing.Range() != alloc.universe { + if persistedRing.Range() != alloc.universe.Range() { overwritePersisted("Deleting persisted data for IPAM range %s; our range is %s", persistedRing.Range(), alloc.universe) return false } diff --git a/ipam/claim.go b/ipam/claim.go index 6ad1b712..fda36f15 100644 --- a/ipam/claim.go +++ b/ipam/claim.go @@ -58,7 +58,7 @@ func (c *claim) Try(alloc *Allocator) bool { case mesh.UnknownPeerName: // If our ring doesn't know, it must be empty. alloc.infof("Claim %s for %s: is in the range %s, but the allocator is not initialized yet; will try later.", - c.cidr, c.ident, alloc.universe.AsCIDRString()) + c.cidr, c.ident, alloc.universe) if c.noErrorOnUnknown { c.sendResult(nil) } diff --git a/ipam/testutils_test.go b/ipam/testutils_test.go index b665771b..13fa8171 100644 --- a/ipam/testutils_test.go +++ b/ipam/testutils_test.go @@ -143,7 +143,7 @@ func makeAllocator(name string, cidrStr string, quorum uint) (*Allocator, addres OurName: peername, OurUID: mesh.PeerUID(rand.Int63()), OurNickname: "nick-" + name, - Universe: cidr.Range(), + Universe: cidr, IsObserver: quorum == 0, Quorum: func() uint { return quorum }, Db: new(mockDB), diff --git a/prog/weaver/main.go b/prog/weaver/main.go index f1d895fd..e185abde 100644 --- a/prog/weaver/main.go +++ b/prog/weaver/main.go @@ -427,7 +427,7 @@ func createAllocator(router *weave.NetworkRouter, config ipamConfig, db db.DB, i OurUID: router.Ourself.Peer.UID, OurNickname: router.Ourself.Peer.NickName, Seed: config.SeedPeerNames, - Universe: ipRange.Range(), + Universe: ipRange, IsObserver: config.Observer, Quorum: func() uint { return determineQuorum(config.PeerCount, router) }, Db: db,