treat it as a single node cluster if empty raft server name

possible fix for https://github.com/chrislusf/seaweedfs/issues/1118
This commit is contained in:
Chris Lu 2020-01-10 00:37:44 -08:00
parent 30c7148020
commit d1ab16b6e3

View file

@ -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