Skip to content

Commit

Permalink
Make host rename on single node more seemless
Browse files Browse the repository at this point in the history
Renaming a host that is a raft peer member is pretty difficult but
we can special case single-node renames since we know all the member
in the cluster and we can update the peer store directly on all nodes
(just one).

Fixes #3632
  • Loading branch information
jwilder committed Aug 13, 2015
1 parent 4c7f07b commit 5280b20
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion meta/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,19 @@ func (r *localRaft) open() error {
return err
}

// Make sure our address is in the raft peers or we won't be able to boot into the cluster
// For single-node clusters, we can update the raft peers before we start the cluster if the hostname
// has changed.
if config.EnableSingleNode {
if err := r.peerStore.SetPeers([]string{s.RemoteAddr.String()}); err != nil {
return err
}
peers = []string{s.RemoteAddr.String()}
}

// If we have multiple nodes in the cluster, make sure our address is in the raft peers or
// we won't be able to boot into the cluster because the other peers will reject our new hostname. This
// is difficult to resolve automatically because we need to have all the raft peers agree on the current members
// of the cluster before we can change them.
if len(peers) > 0 && !raft.PeerContained(peers, s.RemoteAddr.String()) {
s.Logger.Printf("%v is not in the list of raft peers. Please update %v/peers.json on all raft nodes to have the same contents.", s.RemoteAddr.String(), s.Path())
return fmt.Errorf("peers out of sync: %v not in %v", s.RemoteAddr.String(), peers)
Expand Down

0 comments on commit 5280b20

Please sign in to comment.