Skip to content

Commit 15b1c83

Browse files
committed
Revert "Accept an address change in RECOVERY in more cases."
This reverts commit afb8400.
1 parent afb8400 commit 15b1c83

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

service/service.go

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -900,30 +900,15 @@ func (s *Service) HandleHello(ownAddress, remoteAddress string, req *HelloReques
900900
// ID already found, update peer data
901901
for i, p := range s.myPeers.AllPeers {
902902
if p.ID == req.SlaveID {
903+
s.myPeers.AllPeers[i].Port = req.SlavePort
903904
if s.cfg.AllPortOffsetsUnique {
904905
s.myPeers.AllPeers[i].Address = slaveAddr
905906
} else {
906-
// Need to check if this particular address does appear in
907-
// another peer, if so, we forbid to change the address:
908-
addrFound := false
909-
for j, pp := range s.myPeers.AllPeers {
910-
if j != i && pp.Address == slaveAddr {
911-
addrFound = true
912-
break
913-
}
914-
}
915-
// Slave address may not change in this case
916-
if addrFound && p.Address != slaveAddr {
907+
// Slave address may not change
908+
if p.Address != slaveAddr {
917909
return ClusterConfig{}, maskAny(client.NewBadRequestError("Cannot change slave address while using an existing ID."))
918910
}
919-
// We accept the new address (it might be the old one):
920-
s.myPeers.AllPeers[i].Address = slaveAddr
921-
// However, since we also accept the port, we must set the
922-
// port ofset of that replaced peer to 0 such that the AllPeers
923-
// information actually contains the right port.
924-
s.myPeers.AllPeers[i].PortOffset = 0
925911
}
926-
s.myPeers.AllPeers[i].Port = req.SlavePort
927912
s.myPeers.AllPeers[i].DataDir = req.DataDir
928913
}
929914
}

0 commit comments

Comments
 (0)