more readable errors on ring.Merge
There are three significant changes here: - rewrite ring.ErrDifferentSeeds errors - remove the pre-checking of ranges and instead rewrite ring.ErrDifferentRange errors - don't pruneNicknames() and signal ringUpdated() when there was an error We don't rewrite other errors since our current belief is that only ErrDifferentSeeds and ErrDifferentRange can arise from user error.
This commit is contained in:
1 parent
7e0ae6112c
commit
5a45471c68
1 file changed
+13
-9
+13
-9
@@ -618,16 +618,20 @@ func (alloc *Allocator) update(sender router.PeerName, msg []byte) error {
|
||||
// shouldn't get updates for a empty Ring. But tolerate
|
||||
// them just in case.
|
||||
if data.Ring != nil {
|
||||
if data.Ring.Range() != alloc.universe {
|
||||
return fmt.Errorf("Incompatible IP allocation range %s; ours is %s",
|
||||
data.Ring.Range().AsCIDRString(), alloc.universe.AsCIDRString())
|
||||
switch err = alloc.ring.Merge(*data.Ring); err {
|
||||
case ring.ErrDifferentSeeds:
|
||||
return fmt.Errorf("IP allocation was seeded by different peers (received: %v, ours: %v)",
|
||||
data.Ring.Seeds, alloc.ring.Seeds)
|
||||
case ring.ErrDifferentRange:
|
||||
return fmt.Errorf("Incompatible IP allocation ranges (received: %s, ours: %s)",
|
||||
data.Ring.Range().AsCIDRString(), alloc.ring.Range().AsCIDRString())
|
||||
default:
|
||||
if err == nil && !alloc.ring.Empty() {
|
||||
alloc.pruneNicknames()
|
||||
alloc.ringUpdated()
|
||||
}
|
||||
return err
|
||||
}
|
||||
err = alloc.ring.Merge(*data.Ring)
|
||||
if !alloc.ring.Empty() {
|
||||
alloc.pruneNicknames()
|
||||
alloc.ringUpdated()
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
if data.Paxos != nil {
|
||||
|
||||
Reference in new issue
Block a user