Skip to content

Commit

Permalink
Merge pull request #2700 from sethp-nr/patch-3
Browse files Browse the repository at this point in the history
🐛 leadership forwarding for removed members
  • Loading branch information
k8s-ci-robot authored Mar 18, 2020
2 parents ea82875 + 4472a5d commit 5f14f88
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions controlplane/kubeadm/internal/workload_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ func (w *Workload) ForwardEtcdLeadership(ctx context.Context, machine *clusterv1

// TODO we'd probably prefer to pass in all the known nodes and let grpc handle retrying connections across them
clientMachineName := machine.Status.NodeRef.Name
if leaderCandidate != nil && leaderCandidate.Status.NodeRef == nil {
if leaderCandidate != nil && leaderCandidate.Status.NodeRef != nil {
// connect to the new leader candidate, in case machine's etcd membership has already been removed
clientMachineName = leaderCandidate.Status.NodeRef.Name
}
Expand All @@ -537,10 +537,7 @@ func (w *Workload) ForwardEtcdLeadership(ctx context.Context, machine *clusterv1
}

currentMember := etcdutil.MemberForName(members, machine.Status.NodeRef.Name)
if currentMember == nil {
return errors.Errorf("failed to get etcd member from node %q", machine.Status.NodeRef.Name)
}
if currentMember.ID != etcdClient.LeaderID {
if currentMember == nil || currentMember.ID != etcdClient.LeaderID {
return nil
}

Expand Down

0 comments on commit 5f14f88

Please sign in to comment.