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: scale out directly when failover occurs #217

Merged
merged 2 commits into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions pkg/manager/member/pd_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ func (psd *pdScaler) ScaleOut(tc *v1alpha1.TidbCluster, oldSet *apps.StatefulSet
return fmt.Errorf("TidbCluster: %s/%s's pd status sync failed,can't scale out now", ns, tcName)
}

if len(tc.Status.PD.FailureMembers) != 0 {
increaseReplicas(newSet, oldSet)
return nil
}

var i int32 = 0
healthCount := 0
totalCount := *oldSet.Spec.Replicas
Expand Down
20 changes: 20 additions & 0 deletions pkg/manager/member/pd_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,26 @@ func TestPDScalerScaleOut(t *testing.T) {
err: true,
changed: false,
},
{
name: "failover now",
update: func(tc *v1alpha1.TidbCluster) {
normalPDMember(tc)
podName := ordinalPodName(v1alpha1.PDMemberType, tc.GetName(), 0)
tc.Status.PD.FailureMembers = map[string]v1alpha1.PDFailureMember{
podName: {PodName: podName},
}
Copy link
Contributor

Choose a reason for hiding this comment

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

add tc.Status.PD.Members["pd-0"].Health=false

pd := tc.Status.PD.Members[podName]
pd.Health = false
tc.Status.PD.Members[podName] = pd
},
pdUpgrading: false,
hasPVC: true,
hasDeferAnn: true,
pvcDeleteErr: false,
statusSyncFailed: false,
err: false,
changed: true,
},
{
name: "don't have members",
update: func(tc *v1alpha1.TidbCluster) {
Expand Down