Don't use persisted data until we are sure it matches
This commit is contained in:
1 parent
393fa3a333
commit
e96b68f0aa
2 files changed
+14
-2
No files matched your search
+6
-2
@@ -876,11 +876,13 @@ func (alloc *Allocator) loadPersistedData() {
|
||||
if err != nil {
|
||||
alloc.fatalf("Error loading persisted peer name: %s", err)
|
||||
}
|
||||
ringFound, err := alloc.db.Load(ringIdent, &alloc.ring)
|
||||
var persistedRing *ring.Ring
|
||||
ringFound, err := alloc.db.Load(ringIdent, &persistedRing)
|
||||
if err != nil {
|
||||
alloc.fatalf("Error loading persisted IPAM data: %s", err)
|
||||
}
|
||||
ownedFound, err := alloc.db.Load(ownedIdent, &alloc.owned)
|
||||
var persistedOwned map[string]ownedData
|
||||
ownedFound, err := alloc.db.Load(ownedIdent, &persistedOwned)
|
||||
if err != nil {
|
||||
alloc.fatalf("Error loading persisted address data: %s", err)
|
||||
}
|
||||
@@ -891,9 +893,11 @@ func (alloc *Allocator) loadPersistedData() {
|
||||
if len(alloc.seed) != 0 {
|
||||
alloc.infof("Found persisted IPAM data, ignoring supplied IPAM seed")
|
||||
}
|
||||
alloc.ring = persistedRing
|
||||
alloc.space.UpdateRanges(alloc.ring.OwnedRanges())
|
||||
}
|
||||
if ownedFound {
|
||||
alloc.owned = persistedOwned
|
||||
for _, d := range alloc.owned {
|
||||
for _, cidr := range d.Cidrs {
|
||||
alloc.space.Claim(cidr.Addr)
|
||||
|
||||
@@ -19,4 +19,12 @@ weave_on $HOST2 connect $HOST1
|
||||
assert_raises "exec_on $HOST1 c1 $PING c2"
|
||||
assert_raises "exec_on $HOST2 c2 $PING c1"
|
||||
|
||||
# Now restart one router with a different peername
|
||||
docker_on $HOST2 rm -f c2 >/dev/null
|
||||
weave_on $HOST2 forget $HOST1
|
||||
weave_on $HOST2 stop
|
||||
weave_on $HOST2 launch --name ::3
|
||||
# Check that this host has not retained the previous IPAM data
|
||||
assert "weave_on $HOST2 status ipam" ""
|
||||
|
||||
end_suite
|
||||
Reference in new issue
Block a user