From 3019246742ff5e60633ec4b5dc12633cf6690a6c Mon Sep 17 00:00:00 2001 From: galal-hussein Date: Fri, 11 Sep 2020 21:17:06 +0200 Subject: [PATCH] etcdserver: add ConfChangeAddLearnerNode to the list of config changes To fix a panic that happens when trying to get ids of etcd members in force new cluster mode, the issue happen if the cluster previously had etcd learner nodes added to the cluster Fixes #12285 --- etcdserver/raft.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/etcdserver/raft.go b/etcdserver/raft.go index df08e3de3..22d0c0173 100644 --- a/etcdserver/raft.go +++ b/etcdserver/raft.go @@ -675,10 +675,11 @@ func restartAsStandaloneNode(cfg ServerConfig, snapshot *raftpb.Snapshot) (types } // getIDs returns an ordered set of IDs included in the given snapshot and -// the entries. The given snapshot/entries can contain two kinds of +// the entries. The given snapshot/entries can contain three kinds of // ID-related entry: // - ConfChangeAddNode, in which case the contained ID will be added into the set. // - ConfChangeRemoveNode, in which case the contained ID will be removed from the set. +// - ConfChangeAddLearnerNode, in which the contained ID will be added into the set. func getIDs(lg *zap.Logger, snap *raftpb.Snapshot, ents []raftpb.Entry) []uint64 { ids := make(map[uint64]bool) if snap != nil { @@ -693,6 +694,8 @@ func getIDs(lg *zap.Logger, snap *raftpb.Snapshot, ents []raftpb.Entry) []uint64 var cc raftpb.ConfChange pbutil.MustUnmarshal(&cc, e.Data) switch cc.Type { + case raftpb.ConfChangeAddLearnerNode: + ids[cc.NodeID] = true case raftpb.ConfChangeAddNode: ids[cc.NodeID] = true case raftpb.ConfChangeRemoveNode: