etcdserver: update raftStatus
parent
e994a4df01
commit
3f94385fc6
|
@ -1699,7 +1699,7 @@ func (s *EtcdServer) promoteMember(ctx context.Context, id uint64) ([]*membershi
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *EtcdServer) mayPromoteMember(id types.ID) error {
|
func (s *EtcdServer) mayPromoteMember(id types.ID) error {
|
||||||
err := isLearnerReady(uint64(id))
|
err := s.isLearnerReady(uint64(id))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1727,12 +1727,8 @@ func (s *EtcdServer) mayPromoteMember(id types.ID) error {
|
||||||
// check whether the learner catches up with leader or not.
|
// check whether the learner catches up with leader or not.
|
||||||
// Note: it will return nil if member is not found in cluster or if member is not learner.
|
// Note: it will return nil if member is not found in cluster or if member is not learner.
|
||||||
// These two conditions will be checked before apply phase later.
|
// These two conditions will be checked before apply phase later.
|
||||||
func isLearnerReady(id uint64) error {
|
func (s *EtcdServer) isLearnerReady(id uint64) error {
|
||||||
// sanity check, this can happen in the unit test when we do not start node.
|
rs := s.raftStatus()
|
||||||
if raftStatus == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
rs := raftStatus()
|
|
||||||
|
|
||||||
// leader's raftStatus.Progress is not nil
|
// leader's raftStatus.Progress is not nil
|
||||||
if rs.Progress == nil {
|
if rs.Progress == nil {
|
||||||
|
@ -2612,3 +2608,8 @@ func (s *EtcdServer) IsLearner() bool {
|
||||||
func (s *EtcdServer) IsMemberExist(id types.ID) bool {
|
func (s *EtcdServer) IsMemberExist(id types.ID) bool {
|
||||||
return s.cluster.IsMemberExist(id)
|
return s.cluster.IsMemberExist(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// raftStatus returns the raft status of this etcd node.
|
||||||
|
func (s *EtcdServer) raftStatus() raft.Status {
|
||||||
|
return s.r.Node.Status()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue