code: func (rm *roleManager) removeMember(ctx context.Context, member *membership.Member) {
  	// Quorum safeguard - quorum should have been checked before a node was allowed to be demoted, but if in the
  	// intervening time some other node disconnected, removing this node would result in a loss of cluster quorum.
  	// We leave it
  	if !rm.raft.CanRemoveMember(member.RaftID) {
  		// TODO(aaronl): Retry later
  		log.G(ctx).Debugf("can't demote node %s at this time: removing member from raft would result in a loss of quorum", member.NodeID)
  		return
  	}
  
  	rmCtx, rmCancel := context.WithTimeout(rm.ctx, removalTimeout)
  	defer rmCancel()
  
  	if member.RaftID == rm.raft.Config.ID {
  		// Don't use rmCtx, because we expect to lose
  		// leadership, which will cancel this context.
  		log.G(ctx).Info("demoted; transferring leadership")
  		err := rm.raft.TransferLeadership(context.Background())
  		if err == nil {
  			return
  		}
  		log.G(ctx).WithError(err).Info("failed to transfer leadership")
  	}
  	if err := rm.raft.RemoveMember(rmCtx, member.RaftID); err != nil {
  		// TODO(aaronl): Retry later
  		log.G(ctx).WithError(err).Debugf("can't demote node %s at this time", member.NodeID)
  	}
  }
docs: // removeMember removes a member from the raft cluster membership