Skip to content

Commit

Permalink
fix pd-failover: scale out directly when failover occurs (#217)
Browse files Browse the repository at this point in the history
* fix pd-failover: scale out directly when failover occurs

* address comment
  • Loading branch information
weekface authored and xiaojingchen committed Dec 6, 2018
1 parent ebcb306 commit b9ba8ba
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
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},
}
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

0 comments on commit b9ba8ba

Please sign in to comment.