From d1ab16b6e312b8a218b974ecf9caa3d4b0103eb6 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 10 Jan 2020 00:37:44 -0800 Subject: [PATCH] treat it as a single node cluster if empty raft server name possible fix for https://github.com/chrislusf/seaweedfs/issues/1118 --- weed/topology/topology.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/weed/topology/topology.go b/weed/topology/topology.go index e6cb44727..fbf998707 100644 --- a/weed/topology/topology.go +++ b/weed/topology/topology.go @@ -60,7 +60,12 @@ func NewTopology(id string, seq sequence.Sequencer, volumeSizeLimit uint64, puls func (t *Topology) IsLeader() bool { if t.RaftServer != nil { - return t.RaftServer.State() == raft.Leader + if t.RaftServer.State() == raft.Leader { + return true + } + if t.RaftServer.Leader() == "" { + return true + } } return false } @@ -75,7 +80,7 @@ func (t *Topology) Leader() (string, error) { if l == "" { // We are a single node cluster, we are the leader - return t.RaftServer.Name(), errors.New("Raft Server not initialized!") + return t.RaftServer.Name(), nil } return l, nil @@ -152,7 +157,7 @@ func (t *Topology) ListCollections(includeNormalVolumes, includeEcVolumes bool) t.ecShardMapLock.RUnlock() } - for k, _ := range mapOfCollections { + for k := range mapOfCollections { ret = append(ret, k) } return ret