Merge pull request #2345 from weaveworks/issues/2344-persist-more
Fix ring persistence after free space update
This commit is contained in:
commit
adcb1018df
2 files changed
+8
-4
No files matched your search
+3
-1
@@ -911,7 +911,9 @@ func (alloc *Allocator) reportFreeSpace() {
|
||||
for _, r := range ranges {
|
||||
freespace[r.Start] = alloc.space.NumFreeAddressesInRange(r)
|
||||
}
|
||||
alloc.ring.ReportFree(freespace)
|
||||
if alloc.ring.ReportFree(freespace) {
|
||||
alloc.persistRing()
|
||||
}
|
||||
}
|
||||
|
||||
// Persistent data
|
||||
|
||||
+5
-3
@@ -449,8 +449,8 @@ func (r *Ring) String() string {
|
||||
|
||||
// ReportFree is used by the allocator to tell the ring how many free
|
||||
// ips are in a given range, so that ChoosePeersToAskForSpace can make
|
||||
// more intelligent decisions.
|
||||
func (r *Ring) ReportFree(freespace map[address.Address]address.Count) {
|
||||
// more intelligent decisions. Returns true if any changes made.
|
||||
func (r *Ring) ReportFree(freespace map[address.Address]address.Count) (updated bool) {
|
||||
r.assertInvariants()
|
||||
defer r.assertInvariants()
|
||||
defer r.updateExportedVariables()
|
||||
@@ -483,12 +483,14 @@ func (r *Ring) ReportFree(freespace map[address.Address]address.Count) {
|
||||
common.Assert(free <= address.Count(maxSize))
|
||||
|
||||
if entries[i].Free == free {
|
||||
return
|
||||
continue
|
||||
}
|
||||
|
||||
entries[i].Free = free
|
||||
entries[i].Version++
|
||||
updated = true
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type weightedPeer struct {
|
||||
|
||||
Reference in new issue
Block a user