From 35b50b6603eb8df35f8b8fc4509a3f05982dbfcd 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 force-new-cluster flag is passed to etcd node if the cluster had learner nodes added from before Fixes #12285 --- etcdserver/raft.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/etcdserver/raft.go b/etcdserver/raft.go index e87526793cd8..b965657a5db1 100644 --- a/etcdserver/raft.go +++ b/etcdserver/raft.go @@ -618,6 +618,7 @@ func restartAsStandaloneNode(cfg ServerConfig, snapshot *raftpb.Snapshot) (types // 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 { @@ -632,6 +633,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: