mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
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:
parent
30c7148020
commit
d1ab16b6e3
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue