Skip to content

Commit

Permalink
Fix PD failover (#2570)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yisaer authored May 27, 2020
1 parent d4d9180 commit c75ae12
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/manager/member/pd_failover.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ func (pf *pdFailover) tryToMarkAPeerAsFailure(tc *v1alpha1.TidbCluster) error {
if pdMember.LastTransitionTime.IsZero() {
continue
}
if !pf.isPodDesired(tc, podName) {
continue
}

if tc.Status.PD.FailureMembers == nil {
tc.Status.PD.FailureMembers = map[string]v1alpha1.PDFailureMember{}
Expand Down Expand Up @@ -257,3 +260,13 @@ func (fpf *fakePDFailover) Failover(_ *v1alpha1.TidbCluster) error {
func (fpf *fakePDFailover) Recover(_ *v1alpha1.TidbCluster) {
return
}

func (pf *pdFailover) isPodDesired(tc *v1alpha1.TidbCluster, podName string) bool {
ordinals := tc.PDStsDesiredOrdinals(true)
ordinal, err := util.GetOrdinalFromPodName(podName)
if err != nil {
klog.Errorf("unexpected pod name %q: %v", podName, err)
return false
}
return ordinals.Has(ordinal)
}

0 comments on commit c75ae12

Please sign in to comment.