mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #3409 from xiang90/fix_force_new
etcdserver: ignore confChangeUpdateNode in getIDs
This commit is contained in:
commit
bc71aab07a
@ -382,6 +382,8 @@ func getIDs(snap *raftpb.Snapshot, ents []raftpb.Entry) []uint64 {
|
|||||||
ids[cc.NodeID] = true
|
ids[cc.NodeID] = true
|
||||||
case raftpb.ConfChangeRemoveNode:
|
case raftpb.ConfChangeRemoveNode:
|
||||||
delete(ids, cc.NodeID)
|
delete(ids, cc.NodeID)
|
||||||
|
case raftpb.ConfChangeUpdateNode:
|
||||||
|
// do nothing
|
||||||
default:
|
default:
|
||||||
plog.Panicf("ConfChange Type should be either ConfChangeAddNode or ConfChangeRemoveNode!")
|
plog.Panicf("ConfChange Type should be either ConfChangeAddNode or ConfChangeRemoveNode!")
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,8 @@ func TestGetIDs(t *testing.T) {
|
|||||||
removecc := &raftpb.ConfChange{Type: raftpb.ConfChangeRemoveNode, NodeID: 2}
|
removecc := &raftpb.ConfChange{Type: raftpb.ConfChangeRemoveNode, NodeID: 2}
|
||||||
removeEntry := raftpb.Entry{Type: raftpb.EntryConfChange, Data: pbutil.MustMarshal(removecc)}
|
removeEntry := raftpb.Entry{Type: raftpb.EntryConfChange, Data: pbutil.MustMarshal(removecc)}
|
||||||
normalEntry := raftpb.Entry{Type: raftpb.EntryNormal}
|
normalEntry := raftpb.Entry{Type: raftpb.EntryNormal}
|
||||||
|
updatecc := &raftpb.ConfChange{Type: raftpb.ConfChangeUpdateNode, NodeID: 2}
|
||||||
|
updateEntry := raftpb.Entry{Type: raftpb.EntryConfChange, Data: pbutil.MustMarshal(updatecc)}
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
confState *raftpb.ConfState
|
confState *raftpb.ConfState
|
||||||
@ -48,6 +50,8 @@ func TestGetIDs(t *testing.T) {
|
|||||||
[]raftpb.Entry{addEntry, removeEntry}, []uint64{1}},
|
[]raftpb.Entry{addEntry, removeEntry}, []uint64{1}},
|
||||||
{&raftpb.ConfState{Nodes: []uint64{1}},
|
{&raftpb.ConfState{Nodes: []uint64{1}},
|
||||||
[]raftpb.Entry{addEntry, normalEntry}, []uint64{1, 2}},
|
[]raftpb.Entry{addEntry, normalEntry}, []uint64{1, 2}},
|
||||||
|
{&raftpb.ConfState{Nodes: []uint64{1}},
|
||||||
|
[]raftpb.Entry{addEntry, normalEntry, updateEntry}, []uint64{1, 2}},
|
||||||
{&raftpb.ConfState{Nodes: []uint64{1}},
|
{&raftpb.ConfState{Nodes: []uint64{1}},
|
||||||
[]raftpb.Entry{addEntry, removeEntry, normalEntry}, []uint64{1}},
|
[]raftpb.Entry{addEntry, removeEntry, normalEntry}, []uint64{1}},
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user