From 7ce934cbec3945ae8f7c38f866304e2db518171c Mon Sep 17 00:00:00 2001 From: Tobias Schottdorf Date: Wed, 17 Jul 2019 14:29:45 +0200 Subject: [PATCH] raft: return active config in Status This is useful for debug purposes, and more so once we support joint quorums. --- raft/rawnode_test.go | 8 ++++++++ raft/status.go | 2 ++ 2 files changed, 10 insertions(+) diff --git a/raft/rawnode_test.go b/raft/rawnode_test.go index 781e72844..bfb67bd5d 100644 --- a/raft/rawnode_test.go +++ b/raft/rawnode_test.go @@ -21,6 +21,7 @@ import ( "reflect" "testing" + "go.etcd.io/etcd/raft/quorum" "go.etcd.io/etcd/raft/raftpb" "go.etcd.io/etcd/raft/tracker" ) @@ -460,6 +461,13 @@ func TestRawNodeStatus(t *testing.T) { if exp, act := *rn.raft.prs.Progress[1], status.Progress[1]; !reflect.DeepEqual(exp, act) { t.Fatalf("want: %+v\ngot: %+v", exp, act) } + expCfg := tracker.Config{Voters: quorum.JointConfig{ + quorum.MajorityConfig{1: {}}, + nil, + }} + if !reflect.DeepEqual(expCfg, status.Config) { + t.Fatalf("want: %+v\ngot: %+v", expCfg, status.Config) + } } // TestRawNodeCommitPaginationAfterRestart is the RawNode version of diff --git a/raft/status.go b/raft/status.go index 79e589e8a..7002da535 100644 --- a/raft/status.go +++ b/raft/status.go @@ -28,6 +28,7 @@ type Status struct { SoftState Applied uint64 + Config tracker.Config Progress map[uint64]tracker.Progress LeadTransferee uint64 @@ -54,6 +55,7 @@ func getStatusWithoutProgress(r *raft) Status { s.HardState = r.hardState() s.SoftState = *r.softState() s.Applied = r.raftLog.applied + s.Config = r.prs.Config.Clone() return s }