Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PD failover #2570

Merged
merged 8 commits into from
May 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also delete the non desired members in the failure members as done in https://github.com/pingcap/tidb-operator/pull/2560/files#diff-cff8f7143431f3d6302182e300a81909R58?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it's necessary right now since all failure members will be cleared. anyway, we can revise it later.

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)
}