Change ipam Universe from Range to CIDR
There was no code to initialize it as anything else, and this lets us bake in an assumption that it will always be a CIDR.
This commit is contained in:
1 parent
dbc8b4fe1a
commit
f50fbc002e
5 files changed
+8
-8
No files matched your search
+1
-1
@@ -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
|
||||
}
|
||||
|
||||
+4
-4
@@ -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
|
||||
}
|
||||
|
||||
+1
-1
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
+1
-1
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user