Skip to content

Commit

Permalink
add TiDBScaling function (pingcap#2837) (pingcap#2843)
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>

Co-authored-by: Louis <liuzhi@pingcap.com>
  • Loading branch information
ti-srebot and LinuxGit authored Jul 1, 2020
1 parent 90e4b56 commit 18c2ea3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/apis/pingcap/v1alpha1/tidbcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ func (tc *TidbCluster) TiDBUpgrading() bool {
return tc.Status.TiDB.Phase == UpgradePhase
}

func (tc *TidbCluster) TiDBScaling() bool {
return tc.Status.TiDB.Phase == ScalePhase
}

func (tc *TidbCluster) TiFlashUpgrading() bool {
return tc.Status.TiFlash.Phase == UpgradePhase
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/manager/member/tidb_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,8 @@ func (tmm *tidbMemberManager) syncTidbClusterStatus(tc *v1alpha1.TidbCluster, se
if upgrading && tc.Status.TiKV.Phase != v1alpha1.UpgradePhase &&
tc.Status.PD.Phase != v1alpha1.UpgradePhase && tc.Status.Pump.Phase != v1alpha1.UpgradePhase {
tc.Status.TiDB.Phase = v1alpha1.UpgradePhase
} else if tc.TiDBStsDesiredReplicas() != *set.Spec.Replicas {
tc.Status.TiDB.Phase = v1alpha1.ScalePhase
} else {
tc.Status.TiDB.Phase = v1alpha1.NormalPhase
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/manager/member/tidb_member_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,16 +345,21 @@ func TestTiDBMemberManagerSyncTidbClusterStatus(t *testing.T) {
errExpectFn func(*GomegaWithT, error)
tcExpectFn func(*GomegaWithT, *v1alpha1.TidbCluster)
}
spec := apps.StatefulSetSpec{
Replicas: pointer.Int32Ptr(3),
}
status := apps.StatefulSetStatus{
Replicas: int32(3),
}
now := metav1.Time{Time: time.Now()}
testFn := func(test *testcase, t *testing.T) {
tc := newTidbClusterForPD()
tc.Spec.TiDB.Replicas = int32(3)
tc.Status.PD.Phase = v1alpha1.NormalPhase
tc.Status.TiKV.Phase = v1alpha1.NormalPhase
set := &apps.StatefulSet{
ObjectMeta: metav1.ObjectMeta{},
Spec: spec,
Status: status,
}
if test.updateTC != nil {
Expand Down

0 comments on commit 18c2ea3

Please sign in to comment.