From 8b7bc195069b9d40298fcf47613b75c9ad06635f Mon Sep 17 00:00:00 2001
From: Song Gao <2695690803@qq.com>
Date: Tue, 14 Apr 2020 15:41:55 +0800
Subject: [PATCH 1/9] add tac status
---
.../v1alpha1/tidbclusterautoscaler_types.go | 36 ++++++++++++++++++-
.../autoscaler/autoscaler_manager.go | 11 ++++--
pkg/autoscaler/autoscaler/calculate/cpu.go | 10 ++++++
pkg/autoscaler/autoscaler/calculate/util.go | 7 ++++
pkg/autoscaler/autoscaler/tidb_autoscaler.go | 1 +
pkg/autoscaler/autoscaler/tikv_autoscaler.go | 4 +++
6 files changed, 65 insertions(+), 4 deletions(-)
diff --git a/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go b/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go
index a4639eabd81..11e4893aa04 100644
--- a/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go
+++ b/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go
@@ -149,6 +149,40 @@ type TidbMonitorRef struct {
Name string `json:"name"`
}
-// TODO: sync status
+// +k8s:openapi-gen=true
+// TidbClusterAutoSclaerStatus describe the whole status
type TidbClusterAutoSclaerStatus struct {
+ // Tikv describes the status for the tikv in the last auto-scaling reconciliation
+ // +optional
+ TiKV *TikvAutoScalerStatus `json:"tikv,omitempty"`
+ // Tidb describes the status for the tidb in the last auto-scaling reconciliation
+ // +optional
+ TiDB *TidbAutoScalerStatus `json:"tidb,omitempty"`
+}
+
+type TidbAutoScalerStatus struct {
+ BasicAutoScalerStatus `json:",inline"`
+}
+
+type TikvAutoScalerStatus struct {
+ BasicAutoScalerStatus `json:",inline"`
+}
+
+type BasicAutoScalerStatus struct {
+ // MetricsStatusList describes the metrics status in the last auto-scaling reconciliation
+ // +optional
+ MetricsStatusList []MetricsStatus `json:"metrics,omitempty"`
+ // CurrentReplicas describes the current replicas for the component(tidb/tikv)
+ CurrentReplicas int32 `json:"currentReplicas"`
+ // RecommendedReplicas describes the calculated replicas in the last auto-scaling reconciliation for the component(tidb/tikv)
+ RecommendedReplicas int32 `json:"recommendedReplicas"`
+}
+
+type MetricsStatus struct {
+ // Name indicates the metrics name
+ Name string `json:"name"`
+ // CurrentValue indicates the value calculated in the last auto-scaling reconciliation
+ CurrentValue string `json:"currentValue"`
+ // TargetValue indicates the threshold value for this metrics in auto-scaling
+ ThresholdValue string `json:"thresholdValue"`
}
diff --git a/pkg/autoscaler/autoscaler/autoscaler_manager.go b/pkg/autoscaler/autoscaler/autoscaler_manager.go
index 16784cee1c3..3c823705244 100644
--- a/pkg/autoscaler/autoscaler/autoscaler_manager.go
+++ b/pkg/autoscaler/autoscaler/autoscaler_manager.go
@@ -85,7 +85,7 @@ func (am *autoScalerManager) Sync(tac *v1alpha1.TidbClusterAutoScaler) error {
if err := am.syncTidbClusterReplicas(tac, tc, oldTc); err != nil {
return err
}
- return am.syncAutoScalingStatus(tc, oldTc, tac)
+ return am.updateAutoScaling(oldTc, tac)
}
func (am *autoScalerManager) syncAutoScaling(tc *v1alpha1.TidbCluster, tac *v1alpha1.TidbClusterAutoScaler) error {
@@ -125,9 +125,14 @@ func (am *autoScalerManager) syncTidbClusterReplicas(tac *v1alpha1.TidbClusterAu
return nil
}
-//TODO: sync tac status
-func (am *autoScalerManager) syncAutoScalingStatus(tc *v1alpha1.TidbCluster, oldTc *v1alpha1.TidbCluster,
+func (am *autoScalerManager) updateAutoScaling(oldTc *v1alpha1.TidbCluster,
tac *v1alpha1.TidbClusterAutoScaler) error {
+ if tac.Spec.TiKV != nil {
+ tac.Status.TiKV.CurrentReplicas = oldTc.Status.TiKV.StatefulSet.CurrentReplicas
+ }
+ if tac.Spec.TiDB != nil {
+ tac.Status.TiDB.CurrentReplicas = oldTc.Status.TiDB.StatefulSet.CurrentReplicas
+ }
return am.updateTidbClusterAutoScaler(tac)
}
diff --git a/pkg/autoscaler/autoscaler/calculate/cpu.go b/pkg/autoscaler/autoscaler/calculate/cpu.go
index dcad599ded8..e702c525e8a 100644
--- a/pkg/autoscaler/autoscaler/calculate/cpu.go
+++ b/pkg/autoscaler/autoscaler/calculate/cpu.go
@@ -65,6 +65,16 @@ func CalculateRecomendedReplicasByCpuCosts(tac *v1alpha1.TidbClusterAutoScaler,
if err != nil {
return -1, err
}
+ metrics := v1alpha1.MetricsStatus{
+ Name: "cpu",
+ CurrentValue: fmt.Sprintf("%v", cpuSecsTotal),
+ ThresholdValue: fmt.Sprintf("%v", expectedCpuSecsTotal),
+ }
+ if memberType == v1alpha1.TiKVMemberType {
+ addMetricsStatusIntoMetricsStatusList(metrics, &tac.Status.TiKV.BasicAutoScalerStatus)
+ } else if memberType == v1alpha1.TiDBMemberType {
+ addMetricsStatusIntoMetricsStatusList(metrics, &tac.Status.TiDB.BasicAutoScalerStatus)
+ }
return rc, nil
}
diff --git a/pkg/autoscaler/autoscaler/calculate/util.go b/pkg/autoscaler/autoscaler/calculate/util.go
index 97c3cb5bb14..6d7b34945a9 100644
--- a/pkg/autoscaler/autoscaler/calculate/util.go
+++ b/pkg/autoscaler/autoscaler/calculate/util.go
@@ -59,6 +59,13 @@ func filterContainer(tac *v1alpha1.TidbClusterAutoScaler, sts *appsv1.StatefulSe
return nil, fmt.Errorf("tac[%s/%s]'s Target have not %s container", tac.Namespace, tac.Name, containerName)
}
+func addMetricsStatusIntoMetricsStatusList(metrics v1alpha1.MetricsStatus, basicStatus *v1alpha1.BasicAutoScalerStatus) {
+ if basicStatus.MetricsStatusList == nil {
+ basicStatus.MetricsStatusList = []v1alpha1.MetricsStatus{}
+ }
+ basicStatus.MetricsStatusList = append(basicStatus.MetricsStatusList, metrics)
+}
+
const (
statusSuccess = "success"
)
diff --git a/pkg/autoscaler/autoscaler/tidb_autoscaler.go b/pkg/autoscaler/autoscaler/tidb_autoscaler.go
index ef81ab94e39..c16c464af87 100644
--- a/pkg/autoscaler/autoscaler/tidb_autoscaler.go
+++ b/pkg/autoscaler/autoscaler/tidb_autoscaler.go
@@ -71,6 +71,7 @@ func syncTiDBAfterCalculated(tc *v1alpha1.TidbCluster, tac *v1alpha1.TidbCluster
func updateTcTiDBIfScale(tc *v1alpha1.TidbCluster, tac *v1alpha1.TidbClusterAutoScaler, recommendedReplicas int32) error {
tac.Annotations[label.AnnTiDBLastAutoScalingTimestamp] = fmt.Sprintf("%d", time.Now().Unix())
tc.Spec.TiDB.Replicas = recommendedReplicas
+ tac.Status.TiDB.RecommendedReplicas = recommendedReplicas
return nil
}
diff --git a/pkg/autoscaler/autoscaler/tikv_autoscaler.go b/pkg/autoscaler/autoscaler/tikv_autoscaler.go
index 0d5b519b546..d14cc803ac1 100644
--- a/pkg/autoscaler/autoscaler/tikv_autoscaler.go
+++ b/pkg/autoscaler/autoscaler/tikv_autoscaler.go
@@ -30,6 +30,9 @@ func (am *autoScalerManager) syncTiKV(tc *v1alpha1.TidbCluster, tac *v1alpha1.Ti
if tac.Spec.TiKV == nil {
return nil
}
+ if tac.Status.Tikv == nil {
+ tac.Status.Tikv = &v1alpha1.TikvAutoScalerStatus{}
+ }
sts, err := am.stsLister.StatefulSets(tc.Namespace).Get(operatorUtils.GetStatefulSetName(tc, v1alpha1.TiKVMemberType))
if err != nil {
return err
@@ -100,6 +103,7 @@ func updateTcTiKVIfScale(tc *v1alpha1.TidbCluster, tac *v1alpha1.TidbClusterAuto
}
}
tc.Spec.TiKV.Replicas = recommendedReplicas
+ tac.Status.TiKV.RecommendedReplicas = recommendedReplicas
return nil
}
From 8415bf018849eb49d56de89b24f83f6da7b7e6c2 Mon Sep 17 00:00:00 2001
From: Song Gao <2695690803@qq.com>
Date: Tue, 14 Apr 2020 15:47:50 +0800
Subject: [PATCH 2/9] update
---
docs/api-references/docs.md | 212 +++++++++++++++++-
manifests/crd.yaml | 7 +-
.../pingcap/v1alpha1/openapi_generated.go | 28 +++
.../pingcap/v1alpha1/zz_generated.deepcopy.go | 83 ++++++-
4 files changed, 327 insertions(+), 3 deletions(-)
diff --git a/docs/api-references/docs.md b/docs/api-references/docs.md
index 189656a5fa2..73551af26d5 100644
--- a/docs/api-references/docs.md
+++ b/docs/api-references/docs.md
@@ -2354,6 +2354,61 @@ If not set, the default value is 5.
+BasicAutoScalerStatus
+
+
+(Appears on:
+TidbAutoScalerStatus,
+TikvAutoScalerStatus)
+
+
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+metrics
+
+
+[]MetricsStatus
+
+
+ |
+
+(Optional)
+ MetricsStatusList describes the metrics status in the last auto-scaling reconciliation
+ |
+
+
+
+currentReplicas
+
+int32
+
+ |
+
+ CurrentReplicas describes the current replicas for the component(tidb/tikv)
+ |
+
+
+
+recommendedReplicas
+
+int32
+
+ |
+
+ RecommendedReplicas describes the calculated replicas in the last auto-scaling reconciliation for the component(tidb/tikv)
+ |
+
+
+
Binlog
@@ -3984,6 +4039,57 @@ optional
MemberType represents member type
+MetricsStatus
+
+
+(Appears on:
+BasicAutoScalerStatus)
+
+
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+name
+
+string
+
+ |
+
+ Name indicates the metrics name
+ |
+
+
+
+currentValue
+
+string
+
+ |
+
+ CurrentValue indicates the value calculated in the last auto-scaling reconciliation
+ |
+
+
+
+thresholdValue
+
+string
+
+ |
+
+ TargetValue indicates the threshold value for this metrics in auto-scaling
+ |
+
+
+
MonitorComponentAccessor
@@ -12888,6 +12994,39 @@ BasicAutoScalerSpec
+
TidbAutoScalerStatus
+
+
+(Appears on:
+TidbClusterAutoSclaerStatus)
+
+
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+BasicAutoScalerStatus
+
+
+BasicAutoScalerStatus
+
+
+ |
+
+
+(Members of BasicAutoScalerStatus are embedded into this type.)
+
+ |
+
+
+
TidbClusterAutoScalerSpec
@@ -12983,8 +13122,46 @@ TidbAutoScalerSpec
TidbClusterAutoScaler)
-
TODO: sync status
+TidbClusterAutoSclaerStatus describe the whole status
+
+
+
+Field |
+Description |
+
+
+
+
+
+tikv
+
+
+TikvAutoScalerStatus
+
+
+ |
+
+(Optional)
+ Tikv describes the status for the tikv in the last auto-scaling reconciliation
+ |
+
+
+
+tidb
+
+
+TidbAutoScalerStatus
+
+
+ |
+
+(Optional)
+ Tidb describes the status for the tidb in the last auto-scaling reconciliation
+ |
+
+
+
TidbClusterRef
@@ -13876,6 +14053,39 @@ BasicAutoScalerSpec
+
TikvAutoScalerStatus
+
+
+(Appears on:
+TidbClusterAutoSclaerStatus)
+
+
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+BasicAutoScalerStatus
+
+
+BasicAutoScalerStatus
+
+
+ |
+
+
+(Members of BasicAutoScalerStatus are embedded into this type.)
+
+ |
+
+
+
TxnLocalLatches
diff --git a/manifests/crd.yaml b/manifests/crd.yaml
index 7c4605bae6d..8ebd4c52bb3 100644
--- a/manifests/crd.yaml
+++ b/manifests/crd.yaml
@@ -10768,6 +10768,11 @@ spec:
required:
- cluster
type: object
- status: {}
+ status:
+ description: TidbClusterAutoSclaerStatus describe the whole status
+ properties:
+ tidb: {}
+ tikv: {}
+ type: object
type: object
version: v1alpha1
diff --git a/pkg/apis/pingcap/v1alpha1/openapi_generated.go b/pkg/apis/pingcap/v1alpha1/openapi_generated.go
index 18c0663c611..41d449c0a0d 100644
--- a/pkg/apis/pingcap/v1alpha1/openapi_generated.go
+++ b/pkg/apis/pingcap/v1alpha1/openapi_generated.go
@@ -116,6 +116,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TidbClusterAutoScaler": schema_pkg_apis_pingcap_v1alpha1_TidbClusterAutoScaler(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TidbClusterAutoScalerList": schema_pkg_apis_pingcap_v1alpha1_TidbClusterAutoScalerList(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TidbClusterAutoScalerSpec": schema_pkg_apis_pingcap_v1alpha1_TidbClusterAutoScalerSpec(ref),
+ "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TidbClusterAutoSclaerStatus": schema_pkg_apis_pingcap_v1alpha1_TidbClusterAutoSclaerStatus(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TidbClusterList": schema_pkg_apis_pingcap_v1alpha1_TidbClusterList(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TidbClusterRef": schema_pkg_apis_pingcap_v1alpha1_TidbClusterRef(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TidbClusterSpec": schema_pkg_apis_pingcap_v1alpha1_TidbClusterSpec(ref),
@@ -6900,6 +6901,33 @@ func schema_pkg_apis_pingcap_v1alpha1_TidbClusterAutoScalerSpec(ref common.Refer
}
}
+func schema_pkg_apis_pingcap_v1alpha1_TidbClusterAutoSclaerStatus(ref common.ReferenceCallback) common.OpenAPIDefinition {
+ return common.OpenAPIDefinition{
+ Schema: spec.Schema{
+ SchemaProps: spec.SchemaProps{
+ Description: "TidbClusterAutoSclaerStatus describe the whole status",
+ Type: []string{"object"},
+ Properties: map[string]spec.Schema{
+ "tikv": {
+ SchemaProps: spec.SchemaProps{
+ Description: "Tikv describes the status for the tikv in the last auto-scaling reconciliation",
+ Ref: ref("github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TikvAutoScalerStatus"),
+ },
+ },
+ "tidb": {
+ SchemaProps: spec.SchemaProps{
+ Description: "Tidb describes the status for the tidb in the last auto-scaling reconciliation",
+ Ref: ref("github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TidbAutoScalerStatus"),
+ },
+ },
+ },
+ },
+ },
+ Dependencies: []string{
+ "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TidbAutoScalerStatus", "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TikvAutoScalerStatus"},
+ }
+}
+
func schema_pkg_apis_pingcap_v1alpha1_TidbClusterList(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
diff --git a/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go
index 4d30fc65f6d..ff88786d427 100644
--- a/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go
@@ -384,6 +384,27 @@ func (in *BasicAutoScalerSpec) DeepCopy() *BasicAutoScalerSpec {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *BasicAutoScalerStatus) DeepCopyInto(out *BasicAutoScalerStatus) {
+ *out = *in
+ if in.MetricsStatusList != nil {
+ in, out := &in.MetricsStatusList, &out.MetricsStatusList
+ *out = make([]MetricsStatus, len(*in))
+ copy(*out, *in)
+ }
+ return
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BasicAutoScalerStatus.
+func (in *BasicAutoScalerStatus) DeepCopy() *BasicAutoScalerStatus {
+ if in == nil {
+ return nil
+ }
+ out := new(BasicAutoScalerStatus)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Binlog) DeepCopyInto(out *Binlog) {
*out = *in
@@ -1357,6 +1378,22 @@ func (in *MasterKeyKMSConfig) DeepCopy() *MasterKeyKMSConfig {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *MetricsStatus) DeepCopyInto(out *MetricsStatus) {
+ *out = *in
+ return
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricsStatus.
+func (in *MetricsStatus) DeepCopy() *MetricsStatus {
+ if in == nil {
+ return nil
+ }
+ out := new(MetricsStatus)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MonitorContainer) DeepCopyInto(out *MonitorContainer) {
*out = *in
@@ -4810,6 +4847,23 @@ func (in *TidbAutoScalerSpec) DeepCopy() *TidbAutoScalerSpec {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *TidbAutoScalerStatus) DeepCopyInto(out *TidbAutoScalerStatus) {
+ *out = *in
+ in.BasicAutoScalerStatus.DeepCopyInto(&out.BasicAutoScalerStatus)
+ return
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TidbAutoScalerStatus.
+func (in *TidbAutoScalerStatus) DeepCopy() *TidbAutoScalerStatus {
+ if in == nil {
+ return nil
+ }
+ out := new(TidbAutoScalerStatus)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TidbCluster) DeepCopyInto(out *TidbCluster) {
*out = *in
@@ -4844,7 +4898,7 @@ func (in *TidbClusterAutoScaler) DeepCopyInto(out *TidbClusterAutoScaler) {
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
- out.Status = in.Status
+ in.Status.DeepCopyInto(&out.Status)
return
}
@@ -4939,6 +4993,16 @@ func (in *TidbClusterAutoScalerSpec) DeepCopy() *TidbClusterAutoScalerSpec {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TidbClusterAutoSclaerStatus) DeepCopyInto(out *TidbClusterAutoSclaerStatus) {
*out = *in
+ if in.TiKV != nil {
+ in, out := &in.TiKV, &out.TiKV
+ *out = new(TikvAutoScalerStatus)
+ (*in).DeepCopyInto(*out)
+ }
+ if in.TiDB != nil {
+ in, out := &in.TiDB, &out.TiDB
+ *out = new(TidbAutoScalerStatus)
+ (*in).DeepCopyInto(*out)
+ }
return
}
@@ -5407,6 +5471,23 @@ func (in *TikvAutoScalerSpec) DeepCopy() *TikvAutoScalerSpec {
return out
}
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *TikvAutoScalerStatus) DeepCopyInto(out *TikvAutoScalerStatus) {
+ *out = *in
+ in.BasicAutoScalerStatus.DeepCopyInto(&out.BasicAutoScalerStatus)
+ return
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TikvAutoScalerStatus.
+func (in *TikvAutoScalerStatus) DeepCopy() *TikvAutoScalerStatus {
+ if in == nil {
+ return nil
+ }
+ out := new(TikvAutoScalerStatus)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TxnLocalLatches) DeepCopyInto(out *TxnLocalLatches) {
*out = *in
From 69f5af8fc4a0f8aeee85ce80a0bfbeb5c439bc64 Mon Sep 17 00:00:00 2001
From: Song Gao <2695690803@qq.com>
Date: Tue, 14 Apr 2020 16:18:10 +0800
Subject: [PATCH 3/9] fix status
---
examples/auto-scale/tidb-cluster.yaml | 9 ++++++---
pkg/autoscaler/autoscaler/calculate/cpu.go | 2 +-
pkg/autoscaler/autoscaler/calculate/util.go | 7 +++++++
pkg/autoscaler/autoscaler/tidb_autoscaler.go | 3 +++
pkg/autoscaler/autoscaler/tikv_autoscaler.go | 4 ++--
5 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/examples/auto-scale/tidb-cluster.yaml b/examples/auto-scale/tidb-cluster.yaml
index f46ba9a659a..42f1903fe1f 100644
--- a/examples/auto-scale/tidb-cluster.yaml
+++ b/examples/auto-scale/tidb-cluster.yaml
@@ -8,19 +8,22 @@ spec:
pvReclaimPolicy: Delete
pd:
baseImage: pingcap/pd
- replicas: 3
+ replicas: 1
requests:
storage: "1Gi"
config: {}
tikv:
baseImage: pingcap/tikv
- replicas: 3
+ replicas: 1
requests:
+ cpu: "1"
storage: "1Gi"
config: {}
tidb:
baseImage: pingcap/tidb
- replicas: 2
+ replicas: 1
service:
type: ClusterIP
config: {}
+ requests:
+ cpu: "1"
diff --git a/pkg/autoscaler/autoscaler/calculate/cpu.go b/pkg/autoscaler/autoscaler/calculate/cpu.go
index e702c525e8a..2d803fe205b 100644
--- a/pkg/autoscaler/autoscaler/calculate/cpu.go
+++ b/pkg/autoscaler/autoscaler/calculate/cpu.go
@@ -66,7 +66,7 @@ func CalculateRecomendedReplicasByCpuCosts(tac *v1alpha1.TidbClusterAutoScaler,
return -1, err
}
metrics := v1alpha1.MetricsStatus{
- Name: "cpu",
+ Name: string(MetricTypeCPU),
CurrentValue: fmt.Sprintf("%v", cpuSecsTotal),
ThresholdValue: fmt.Sprintf("%v", expectedCpuSecsTotal),
}
diff --git a/pkg/autoscaler/autoscaler/calculate/util.go b/pkg/autoscaler/autoscaler/calculate/util.go
index 6d7b34945a9..14ded46ec97 100644
--- a/pkg/autoscaler/autoscaler/calculate/util.go
+++ b/pkg/autoscaler/autoscaler/calculate/util.go
@@ -63,7 +63,14 @@ func addMetricsStatusIntoMetricsStatusList(metrics v1alpha1.MetricsStatus, basic
if basicStatus.MetricsStatusList == nil {
basicStatus.MetricsStatusList = []v1alpha1.MetricsStatus{}
}
+ for id, m := range basicStatus.MetricsStatusList {
+ if m.Name == metrics.Name {
+ basicStatus.MetricsStatusList[id] = metrics
+ return
+ }
+ }
basicStatus.MetricsStatusList = append(basicStatus.MetricsStatusList, metrics)
+ return
}
const (
diff --git a/pkg/autoscaler/autoscaler/tidb_autoscaler.go b/pkg/autoscaler/autoscaler/tidb_autoscaler.go
index c16c464af87..5943b6f48e2 100644
--- a/pkg/autoscaler/autoscaler/tidb_autoscaler.go
+++ b/pkg/autoscaler/autoscaler/tidb_autoscaler.go
@@ -29,6 +29,9 @@ func (am *autoScalerManager) syncTiDB(tc *v1alpha1.TidbCluster, tac *v1alpha1.Ti
if tac.Spec.TiDB == nil {
return nil
}
+ if tac.Status.TiDB == nil {
+ tac.Status.TiDB = &v1alpha1.TidbAutoScalerStatus{}
+ }
sts, err := am.stsLister.StatefulSets(tc.Namespace).Get(operatorUtils.GetStatefulSetName(tc, v1alpha1.TiDBMemberType))
if err != nil {
return err
diff --git a/pkg/autoscaler/autoscaler/tikv_autoscaler.go b/pkg/autoscaler/autoscaler/tikv_autoscaler.go
index d14cc803ac1..9135635710b 100644
--- a/pkg/autoscaler/autoscaler/tikv_autoscaler.go
+++ b/pkg/autoscaler/autoscaler/tikv_autoscaler.go
@@ -30,8 +30,8 @@ func (am *autoScalerManager) syncTiKV(tc *v1alpha1.TidbCluster, tac *v1alpha1.Ti
if tac.Spec.TiKV == nil {
return nil
}
- if tac.Status.Tikv == nil {
- tac.Status.Tikv = &v1alpha1.TikvAutoScalerStatus{}
+ if tac.Status.TiKV == nil {
+ tac.Status.TiKV = &v1alpha1.TikvAutoScalerStatus{}
}
sts, err := am.stsLister.StatefulSets(tc.Namespace).Get(operatorUtils.GetStatefulSetName(tc, v1alpha1.TiKVMemberType))
if err != nil {
From 8fd1e9540a3f5025417ce2b85add0985ab68abd5 Mon Sep 17 00:00:00 2001
From: Song Gao <2695690803@qq.com>
Date: Tue, 14 Apr 2020 16:30:16 +0800
Subject: [PATCH 4/9] update rc
---
docs/api-references/docs.md | 1 +
pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go | 3 ++-
pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go | 5 +++++
pkg/autoscaler/autoscaler/tidb_autoscaler.go | 2 +-
pkg/autoscaler/autoscaler/tikv_autoscaler.go | 2 +-
5 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/docs/api-references/docs.md b/docs/api-references/docs.md
index 73551af26d5..2ec9ffcbb90 100644
--- a/docs/api-references/docs.md
+++ b/docs/api-references/docs.md
@@ -2404,6 +2404,7 @@ int32
+(Optional)
RecommendedReplicas describes the calculated replicas in the last auto-scaling reconciliation for the component(tidb/tikv)
|
diff --git a/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go b/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go
index 11e4893aa04..604021c320d 100644
--- a/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go
+++ b/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go
@@ -175,7 +175,8 @@ type BasicAutoScalerStatus struct {
// CurrentReplicas describes the current replicas for the component(tidb/tikv)
CurrentReplicas int32 `json:"currentReplicas"`
// RecommendedReplicas describes the calculated replicas in the last auto-scaling reconciliation for the component(tidb/tikv)
- RecommendedReplicas int32 `json:"recommendedReplicas"`
+ // +optional
+ RecommendedReplicas *int32 `json:"recommendedReplicas"`
}
type MetricsStatus struct {
diff --git a/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go
index ff88786d427..e2ee53aaec8 100644
--- a/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go
@@ -392,6 +392,11 @@ func (in *BasicAutoScalerStatus) DeepCopyInto(out *BasicAutoScalerStatus) {
*out = make([]MetricsStatus, len(*in))
copy(*out, *in)
}
+ if in.RecommendedReplicas != nil {
+ in, out := &in.RecommendedReplicas, &out.RecommendedReplicas
+ *out = new(int32)
+ **out = **in
+ }
return
}
diff --git a/pkg/autoscaler/autoscaler/tidb_autoscaler.go b/pkg/autoscaler/autoscaler/tidb_autoscaler.go
index 5943b6f48e2..9b130ec8ce6 100644
--- a/pkg/autoscaler/autoscaler/tidb_autoscaler.go
+++ b/pkg/autoscaler/autoscaler/tidb_autoscaler.go
@@ -74,7 +74,7 @@ func syncTiDBAfterCalculated(tc *v1alpha1.TidbCluster, tac *v1alpha1.TidbCluster
func updateTcTiDBIfScale(tc *v1alpha1.TidbCluster, tac *v1alpha1.TidbClusterAutoScaler, recommendedReplicas int32) error {
tac.Annotations[label.AnnTiDBLastAutoScalingTimestamp] = fmt.Sprintf("%d", time.Now().Unix())
tc.Spec.TiDB.Replicas = recommendedReplicas
- tac.Status.TiDB.RecommendedReplicas = recommendedReplicas
+ tac.Status.TiDB.RecommendedReplicas = &recommendedReplicas
return nil
}
diff --git a/pkg/autoscaler/autoscaler/tikv_autoscaler.go b/pkg/autoscaler/autoscaler/tikv_autoscaler.go
index 9135635710b..b36c00e6017 100644
--- a/pkg/autoscaler/autoscaler/tikv_autoscaler.go
+++ b/pkg/autoscaler/autoscaler/tikv_autoscaler.go
@@ -103,7 +103,7 @@ func updateTcTiKVIfScale(tc *v1alpha1.TidbCluster, tac *v1alpha1.TidbClusterAuto
}
}
tc.Spec.TiKV.Replicas = recommendedReplicas
- tac.Status.TiKV.RecommendedReplicas = recommendedReplicas
+ tac.Status.TiKV.RecommendedReplicas = &recommendedReplicas
return nil
}
From 9dca4dd1f5dfdea9a3267989a315e341b5d39e84 Mon Sep 17 00:00:00 2001
From: Song Gao <2695690803@qq.com>
Date: Tue, 14 Apr 2020 16:32:18 +0800
Subject: [PATCH 5/9] revert replicas
---
examples/auto-scale/tidb-cluster.yaml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/examples/auto-scale/tidb-cluster.yaml b/examples/auto-scale/tidb-cluster.yaml
index 42f1903fe1f..9c3c94f86b8 100644
--- a/examples/auto-scale/tidb-cluster.yaml
+++ b/examples/auto-scale/tidb-cluster.yaml
@@ -8,20 +8,20 @@ spec:
pvReclaimPolicy: Delete
pd:
baseImage: pingcap/pd
- replicas: 1
+ replicas: 3
requests:
storage: "1Gi"
config: {}
tikv:
baseImage: pingcap/tikv
- replicas: 1
+ replicas: 3
requests:
cpu: "1"
storage: "1Gi"
config: {}
tidb:
baseImage: pingcap/tidb
- replicas: 1
+ replicas: 2
service:
type: ClusterIP
config: {}
From 5a5c07bf76feb3bf6cb24e2da7a9c57805d58262 Mon Sep 17 00:00:00 2001
From: Song Gao <2695690803@qq.com>
Date: Tue, 14 Apr 2020 16:40:55 +0800
Subject: [PATCH 6/9] update notes
---
docs/api-references/docs.md | 4 +
manifests/crd.yaml | 84 ++++++++-
.../pingcap/v1alpha1/openapi_generated.go | 168 ++++++++++++++++++
.../v1alpha1/tidbclusterautoscaler_types.go | 8 +
4 files changed, 262 insertions(+), 2 deletions(-)
diff --git a/docs/api-references/docs.md b/docs/api-references/docs.md
index 2ec9ffcbb90..4516572d664 100644
--- a/docs/api-references/docs.md
+++ b/docs/api-references/docs.md
@@ -2362,6 +2362,7 @@ If not set, the default value is 5.
TikvAutoScalerStatus)
+
BasicAutoScalerStatus describe the basic auto-scaling status
@@ -4047,6 +4048,7 @@ optional
BasicAutoScalerStatus)
+
MetricsStatus describe the basic metrics status in the last auto-scaling reconciliation
@@ -13002,6 +13004,7 @@ BasicAutoScalerSpec
TidbClusterAutoSclaerStatus)
+
TidbAutoScalerStatus describe the auto-scaling status of tidb
@@ -14061,6 +14064,7 @@ BasicAutoScalerSpec
TidbClusterAutoSclaerStatus)
+
TikvAutoScalerStatus describe the auto-scaling status of tikv
diff --git a/manifests/crd.yaml b/manifests/crd.yaml
index 8ebd4c52bb3..3c5e342cc08 100644
--- a/manifests/crd.yaml
+++ b/manifests/crd.yaml
@@ -10771,8 +10771,88 @@ spec:
status:
description: TidbClusterAutoSclaerStatus describe the whole status
properties:
- tidb: {}
- tikv: {}
+ tidb:
+ description: TidbAutoScalerStatus describe the auto-scaling status of
+ tidb
+ properties:
+ currentReplicas:
+ description: CurrentReplicas describes the current replicas for
+ the component(tidb/tikv)
+ format: int32
+ type: integer
+ metrics:
+ description: MetricsStatusList describes the metrics status in the
+ last auto-scaling reconciliation
+ items:
+ description: MetricsStatus describe the basic metrics status in
+ the last auto-scaling reconciliation
+ properties:
+ currentValue:
+ description: CurrentValue indicates the value calculated in
+ the last auto-scaling reconciliation
+ type: string
+ name:
+ description: Name indicates the metrics name
+ type: string
+ thresholdValue:
+ description: TargetValue indicates the threshold value for
+ this metrics in auto-scaling
+ type: string
+ required:
+ - name
+ - currentValue
+ - thresholdValue
+ type: object
+ type: array
+ recommendedReplicas:
+ description: RecommendedReplicas describes the calculated replicas
+ in the last auto-scaling reconciliation for the component(tidb/tikv)
+ format: int32
+ type: integer
+ required:
+ - currentReplicas
+ type: object
+ tikv:
+ description: TikvAutoScalerStatus describe the auto-scaling status of
+ tikv
+ properties:
+ currentReplicas:
+ description: CurrentReplicas describes the current replicas for
+ the component(tidb/tikv)
+ format: int32
+ type: integer
+ metrics:
+ description: MetricsStatusList describes the metrics status in the
+ last auto-scaling reconciliation
+ items:
+ description: MetricsStatus describe the basic metrics status in
+ the last auto-scaling reconciliation
+ properties:
+ currentValue:
+ description: CurrentValue indicates the value calculated in
+ the last auto-scaling reconciliation
+ type: string
+ name:
+ description: Name indicates the metrics name
+ type: string
+ thresholdValue:
+ description: TargetValue indicates the threshold value for
+ this metrics in auto-scaling
+ type: string
+ required:
+ - name
+ - currentValue
+ - thresholdValue
+ type: object
+ type: array
+ recommendedReplicas:
+ description: RecommendedReplicas describes the calculated replicas
+ in the last auto-scaling reconciliation for the component(tidb/tikv)
+ format: int32
+ type: integer
+ required:
+ - currentReplicas
+ type: object
type: object
type: object
version: v1alpha1
diff --git a/pkg/apis/pingcap/v1alpha1/openapi_generated.go b/pkg/apis/pingcap/v1alpha1/openapi_generated.go
index 41d449c0a0d..2d8370cef72 100644
--- a/pkg/apis/pingcap/v1alpha1/openapi_generated.go
+++ b/pkg/apis/pingcap/v1alpha1/openapi_generated.go
@@ -35,6 +35,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.BackupScheduleSpec": schema_pkg_apis_pingcap_v1alpha1_BackupScheduleSpec(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.BackupSpec": schema_pkg_apis_pingcap_v1alpha1_BackupSpec(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.BasicAutoScalerSpec": schema_pkg_apis_pingcap_v1alpha1_BasicAutoScalerSpec(ref),
+ "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.BasicAutoScalerStatus": schema_pkg_apis_pingcap_v1alpha1_BasicAutoScalerStatus(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.Binlog": schema_pkg_apis_pingcap_v1alpha1_Binlog(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.CommonConfig": schema_pkg_apis_pingcap_v1alpha1_CommonConfig(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.ComponentSpec": schema_pkg_apis_pingcap_v1alpha1_ComponentSpec(ref),
@@ -50,6 +51,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.LogTailerSpec": schema_pkg_apis_pingcap_v1alpha1_LogTailerSpec(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.MasterKeyFileConfig": schema_pkg_apis_pingcap_v1alpha1_MasterKeyFileConfig(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.MasterKeyKMSConfig": schema_pkg_apis_pingcap_v1alpha1_MasterKeyKMSConfig(ref),
+ "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.MetricsStatus": schema_pkg_apis_pingcap_v1alpha1_MetricsStatus(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.MonitorContainer": schema_pkg_apis_pingcap_v1alpha1_MonitorContainer(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.OpenTracing": schema_pkg_apis_pingcap_v1alpha1_OpenTracing(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.OpenTracingReporter": schema_pkg_apis_pingcap_v1alpha1_OpenTracingReporter(ref),
@@ -112,6 +114,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TiKVTitanCfConfig": schema_pkg_apis_pingcap_v1alpha1_TiKVTitanCfConfig(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TiKVTitanDBConfig": schema_pkg_apis_pingcap_v1alpha1_TiKVTitanDBConfig(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TidbAutoScalerSpec": schema_pkg_apis_pingcap_v1alpha1_TidbAutoScalerSpec(ref),
+ "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TidbAutoScalerStatus": schema_pkg_apis_pingcap_v1alpha1_TidbAutoScalerStatus(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TidbCluster": schema_pkg_apis_pingcap_v1alpha1_TidbCluster(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TidbClusterAutoScaler": schema_pkg_apis_pingcap_v1alpha1_TidbClusterAutoScaler(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TidbClusterAutoScalerList": schema_pkg_apis_pingcap_v1alpha1_TidbClusterAutoScalerList(ref),
@@ -129,6 +132,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TidbMonitorRef": schema_pkg_apis_pingcap_v1alpha1_TidbMonitorRef(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TidbMonitorSpec": schema_pkg_apis_pingcap_v1alpha1_TidbMonitorSpec(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TikvAutoScalerSpec": schema_pkg_apis_pingcap_v1alpha1_TikvAutoScalerSpec(ref),
+ "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TikvAutoScalerStatus": schema_pkg_apis_pingcap_v1alpha1_TikvAutoScalerStatus(ref),
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.TxnLocalLatches": schema_pkg_apis_pingcap_v1alpha1_TxnLocalLatches(ref),
"k8s.io/api/core/v1.AWSElasticBlockStoreVolumeSource": schema_k8sio_api_core_v1_AWSElasticBlockStoreVolumeSource(ref),
"k8s.io/api/core/v1.Affinity": schema_k8sio_api_core_v1_Affinity(ref),
@@ -880,6 +884,49 @@ func schema_pkg_apis_pingcap_v1alpha1_BasicAutoScalerSpec(ref common.ReferenceCa
}
}
+func schema_pkg_apis_pingcap_v1alpha1_BasicAutoScalerStatus(ref common.ReferenceCallback) common.OpenAPIDefinition {
+ return common.OpenAPIDefinition{
+ Schema: spec.Schema{
+ SchemaProps: spec.SchemaProps{
+ Description: "BasicAutoScalerStatus describe the basic auto-scaling status",
+ Type: []string{"object"},
+ Properties: map[string]spec.Schema{
+ "metrics": {
+ SchemaProps: spec.SchemaProps{
+ Description: "MetricsStatusList describes the metrics status in the last auto-scaling reconciliation",
+ Type: []string{"array"},
+ Items: &spec.SchemaOrArray{
+ Schema: &spec.Schema{
+ SchemaProps: spec.SchemaProps{
+ Ref: ref("github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.MetricsStatus"),
+ },
+ },
+ },
+ },
+ },
+ "currentReplicas": {
+ SchemaProps: spec.SchemaProps{
+ Description: "CurrentReplicas describes the current replicas for the component(tidb/tikv)",
+ Type: []string{"integer"},
+ Format: "int32",
+ },
+ },
+ "recommendedReplicas": {
+ SchemaProps: spec.SchemaProps{
+ Description: "RecommendedReplicas describes the calculated replicas in the last auto-scaling reconciliation for the component(tidb/tikv)",
+ Type: []string{"integer"},
+ Format: "int32",
+ },
+ },
+ },
+ Required: []string{"currentReplicas"},
+ },
+ },
+ Dependencies: []string{
+ "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.MetricsStatus"},
+ }
+}
+
func schema_pkg_apis_pingcap_v1alpha1_Binlog(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
@@ -1606,6 +1653,41 @@ func schema_pkg_apis_pingcap_v1alpha1_MasterKeyKMSConfig(ref common.ReferenceCal
}
}
+func schema_pkg_apis_pingcap_v1alpha1_MetricsStatus(ref common.ReferenceCallback) common.OpenAPIDefinition {
+ return common.OpenAPIDefinition{
+ Schema: spec.Schema{
+ SchemaProps: spec.SchemaProps{
+ Description: "MetricsStatus describe the basic metrics status in the last auto-scaling reconciliation",
+ Type: []string{"object"},
+ Properties: map[string]spec.Schema{
+ "name": {
+ SchemaProps: spec.SchemaProps{
+ Description: "Name indicates the metrics name",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ "currentValue": {
+ SchemaProps: spec.SchemaProps{
+ Description: "CurrentValue indicates the value calculated in the last auto-scaling reconciliation",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ "thresholdValue": {
+ SchemaProps: spec.SchemaProps{
+ Description: "TargetValue indicates the threshold value for this metrics in auto-scaling",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
+ },
+ Required: []string{"name", "currentValue", "thresholdValue"},
+ },
+ },
+ }
+}
+
func schema_pkg_apis_pingcap_v1alpha1_MonitorContainer(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
@@ -6734,6 +6816,49 @@ func schema_pkg_apis_pingcap_v1alpha1_TidbAutoScalerSpec(ref common.ReferenceCal
}
}
+func schema_pkg_apis_pingcap_v1alpha1_TidbAutoScalerStatus(ref common.ReferenceCallback) common.OpenAPIDefinition {
+ return common.OpenAPIDefinition{
+ Schema: spec.Schema{
+ SchemaProps: spec.SchemaProps{
+ Description: "TidbAutoScalerStatus describe the auto-scaling status of tidb",
+ Type: []string{"object"},
+ Properties: map[string]spec.Schema{
+ "metrics": {
+ SchemaProps: spec.SchemaProps{
+ Description: "MetricsStatusList describes the metrics status in the last auto-scaling reconciliation",
+ Type: []string{"array"},
+ Items: &spec.SchemaOrArray{
+ Schema: &spec.Schema{
+ SchemaProps: spec.SchemaProps{
+ Ref: ref("github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.MetricsStatus"),
+ },
+ },
+ },
+ },
+ },
+ "currentReplicas": {
+ SchemaProps: spec.SchemaProps{
+ Description: "CurrentReplicas describes the current replicas for the component(tidb/tikv)",
+ Type: []string{"integer"},
+ Format: "int32",
+ },
+ },
+ "recommendedReplicas": {
+ SchemaProps: spec.SchemaProps{
+ Description: "RecommendedReplicas describes the calculated replicas in the last auto-scaling reconciliation for the component(tidb/tikv)",
+ Type: []string{"integer"},
+ Format: "int32",
+ },
+ },
+ },
+ Required: []string{"currentReplicas"},
+ },
+ },
+ Dependencies: []string{
+ "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.MetricsStatus"},
+ }
+}
+
func schema_pkg_apis_pingcap_v1alpha1_TidbCluster(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
@@ -7707,6 +7832,49 @@ func schema_pkg_apis_pingcap_v1alpha1_TikvAutoScalerSpec(ref common.ReferenceCal
}
}
+func schema_pkg_apis_pingcap_v1alpha1_TikvAutoScalerStatus(ref common.ReferenceCallback) common.OpenAPIDefinition {
+ return common.OpenAPIDefinition{
+ Schema: spec.Schema{
+ SchemaProps: spec.SchemaProps{
+ Description: "TikvAutoScalerStatus describe the auto-scaling status of tikv",
+ Type: []string{"object"},
+ Properties: map[string]spec.Schema{
+ "metrics": {
+ SchemaProps: spec.SchemaProps{
+ Description: "MetricsStatusList describes the metrics status in the last auto-scaling reconciliation",
+ Type: []string{"array"},
+ Items: &spec.SchemaOrArray{
+ Schema: &spec.Schema{
+ SchemaProps: spec.SchemaProps{
+ Ref: ref("github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.MetricsStatus"),
+ },
+ },
+ },
+ },
+ },
+ "currentReplicas": {
+ SchemaProps: spec.SchemaProps{
+ Description: "CurrentReplicas describes the current replicas for the component(tidb/tikv)",
+ Type: []string{"integer"},
+ Format: "int32",
+ },
+ },
+ "recommendedReplicas": {
+ SchemaProps: spec.SchemaProps{
+ Description: "RecommendedReplicas describes the calculated replicas in the last auto-scaling reconciliation for the component(tidb/tikv)",
+ Type: []string{"integer"},
+ Format: "int32",
+ },
+ },
+ },
+ Required: []string{"currentReplicas"},
+ },
+ },
+ Dependencies: []string{
+ "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.MetricsStatus"},
+ }
+}
+
func schema_pkg_apis_pingcap_v1alpha1_TxnLocalLatches(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
diff --git a/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go b/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go
index 604021c320d..46e78cb2e18 100644
--- a/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go
+++ b/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go
@@ -160,14 +160,20 @@ type TidbClusterAutoSclaerStatus struct {
TiDB *TidbAutoScalerStatus `json:"tidb,omitempty"`
}
+// +k8s:openapi-gen=true
+// TidbAutoScalerStatus describe the auto-scaling status of tidb
type TidbAutoScalerStatus struct {
BasicAutoScalerStatus `json:",inline"`
}
+// +k8s:openapi-gen=true
+// TikvAutoScalerStatus describe the auto-scaling status of tikv
type TikvAutoScalerStatus struct {
BasicAutoScalerStatus `json:",inline"`
}
+// +k8s:openapi-gen=true
+// BasicAutoScalerStatus describe the basic auto-scaling status
type BasicAutoScalerStatus struct {
// MetricsStatusList describes the metrics status in the last auto-scaling reconciliation
// +optional
@@ -179,6 +185,8 @@ type BasicAutoScalerStatus struct {
RecommendedReplicas *int32 `json:"recommendedReplicas"`
}
+// +k8s:openapi-gen=true
+// MetricsStatus describe the basic metrics status in the last auto-scaling reconciliation
type MetricsStatus struct {
// Name indicates the metrics name
Name string `json:"name"`
From ce28352ca593fb4f8b888e60eea858d0e72c3018 Mon Sep 17 00:00:00 2001
From: Song Gao <2695690803@qq.com>
Date: Wed, 15 Apr 2020 12:55:13 +0800
Subject: [PATCH 7/9] add last ts
---
docs/api-references/docs.md | 12 +++++++
manifests/crd.yaml | 8 +++++
.../pingcap/v1alpha1/openapi_generated.go | 21 ++++++++++++
.../v1alpha1/tidbclusterautoscaler_types.go | 5 ++-
.../pingcap/v1alpha1/zz_generated.deepcopy.go | 5 +++
.../autoscaler/autoscaler_manager.go | 33 +++++++++++++++++++
6 files changed, 83 insertions(+), 1 deletion(-)
diff --git a/docs/api-references/docs.md b/docs/api-references/docs.md
index 4516572d664..b4f075392fe 100644
--- a/docs/api-references/docs.md
+++ b/docs/api-references/docs.md
@@ -2409,6 +2409,18 @@ int32
RecommendedReplicas describes the calculated replicas in the last auto-scaling reconciliation for the component(tidb/tikv)
+
+
+lastAutoScalingTimestamp
+
+string
+
+ |
+
+(Optional)
+ LastAutoScalingTimestamp describes the last auto-scaling timestamp for the component(tidb/tikv)
+ |
+
Binlog
diff --git a/manifests/crd.yaml b/manifests/crd.yaml
index 3c5e342cc08..73ef04d3b1f 100644
--- a/manifests/crd.yaml
+++ b/manifests/crd.yaml
@@ -10780,6 +10780,10 @@ spec:
the component(tidb/tikv)
format: int32
type: integer
+ lastAutoScalingTimestamp:
+ description: LastAutoScalingTimestamp describes the last auto-scaling
+ timestamp for the component(tidb/tikv)
+ type: string
metrics:
description: MetricsStatusList describes the metrics status in the
last auto-scaling reconciliation
@@ -10821,6 +10825,10 @@ spec:
the component(tidb/tikv)
format: int32
type: integer
+ lastAutoScalingTimestamp:
+ description: LastAutoScalingTimestamp describes the last auto-scaling
+ timestamp for the component(tidb/tikv)
+ type: string
metrics:
description: MetricsStatusList describes the metrics status in the
last auto-scaling reconciliation
diff --git a/pkg/apis/pingcap/v1alpha1/openapi_generated.go b/pkg/apis/pingcap/v1alpha1/openapi_generated.go
index 2d8370cef72..e1a4f6e13d4 100644
--- a/pkg/apis/pingcap/v1alpha1/openapi_generated.go
+++ b/pkg/apis/pingcap/v1alpha1/openapi_generated.go
@@ -918,6 +918,13 @@ func schema_pkg_apis_pingcap_v1alpha1_BasicAutoScalerStatus(ref common.Reference
Format: "int32",
},
},
+ "lastAutoScalingTimestamp": {
+ SchemaProps: spec.SchemaProps{
+ Description: "LastAutoScalingTimestamp describes the last auto-scaling timestamp for the component(tidb/tikv)",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
},
Required: []string{"currentReplicas"},
},
@@ -6850,6 +6857,13 @@ func schema_pkg_apis_pingcap_v1alpha1_TidbAutoScalerStatus(ref common.ReferenceC
Format: "int32",
},
},
+ "lastAutoScalingTimestamp": {
+ SchemaProps: spec.SchemaProps{
+ Description: "LastAutoScalingTimestamp describes the last auto-scaling timestamp for the component(tidb/tikv)",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
},
Required: []string{"currentReplicas"},
},
@@ -7866,6 +7880,13 @@ func schema_pkg_apis_pingcap_v1alpha1_TikvAutoScalerStatus(ref common.ReferenceC
Format: "int32",
},
},
+ "lastAutoScalingTimestamp": {
+ SchemaProps: spec.SchemaProps{
+ Description: "LastAutoScalingTimestamp describes the last auto-scaling timestamp for the component(tidb/tikv)",
+ Type: []string{"string"},
+ Format: "",
+ },
+ },
},
Required: []string{"currentReplicas"},
},
diff --git a/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go b/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go
index 46e78cb2e18..06d38230e53 100644
--- a/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go
+++ b/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go
@@ -182,7 +182,10 @@ type BasicAutoScalerStatus struct {
CurrentReplicas int32 `json:"currentReplicas"`
// RecommendedReplicas describes the calculated replicas in the last auto-scaling reconciliation for the component(tidb/tikv)
// +optional
- RecommendedReplicas *int32 `json:"recommendedReplicas"`
+ RecommendedReplicas *int32 `json:"recommendedReplicas,omitempty"`
+ // LastAutoScalingTimestamp describes the last auto-scaling timestamp for the component(tidb/tikv)
+ // +optional
+ LastAutoScalingTimestamp *string `json:"lastAutoScalingTimestamp,omitempty"`
}
// +k8s:openapi-gen=true
diff --git a/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go
index e2ee53aaec8..5041ee236dd 100644
--- a/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go
@@ -397,6 +397,11 @@ func (in *BasicAutoScalerStatus) DeepCopyInto(out *BasicAutoScalerStatus) {
*out = new(int32)
**out = **in
}
+ if in.LastAutoScalingTimestamp != nil {
+ in, out := &in.LastAutoScalingTimestamp, &out.LastAutoScalingTimestamp
+ *out = new(string)
+ **out = **in
+ }
return
}
diff --git a/pkg/autoscaler/autoscaler/autoscaler_manager.go b/pkg/autoscaler/autoscaler/autoscaler_manager.go
index 3c823705244..e0ed8b9577f 100644
--- a/pkg/autoscaler/autoscaler/autoscaler_manager.go
+++ b/pkg/autoscaler/autoscaler/autoscaler_manager.go
@@ -15,13 +15,16 @@ package autoscaler
import (
"fmt"
+ "strconv"
"strings"
+ "time"
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1"
"github.com/pingcap/tidb-operator/pkg/client/clientset/versioned"
informers "github.com/pingcap/tidb-operator/pkg/client/informers/externalversions"
v1alpha1listers "github.com/pingcap/tidb-operator/pkg/client/listers/pingcap/v1alpha1"
"github.com/pingcap/tidb-operator/pkg/controller"
+ "github.com/pingcap/tidb-operator/pkg/label"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -127,11 +130,41 @@ func (am *autoScalerManager) syncTidbClusterReplicas(tac *v1alpha1.TidbClusterAu
func (am *autoScalerManager) updateAutoScaling(oldTc *v1alpha1.TidbCluster,
tac *v1alpha1.TidbClusterAutoScaler) error {
+ if tac.Annotations == nil {
+ tac.Annotations = map[string]string{}
+ }
+ f := func(key string) (string, error) {
+ v, ok := tac.Annotations[key]
+ if ok {
+ ts, err := strconv.ParseInt(v, 10, 64)
+ if err != nil {
+ klog.Errorf("failed to convert label[%s] key to int64, err:%v", key, err)
+ return "", err
+ }
+ return time.Unix(ts, 0).Format(time.RFC3339), nil
+ }
+ return "", nil
+ }
+
if tac.Spec.TiKV != nil {
tac.Status.TiKV.CurrentReplicas = oldTc.Status.TiKV.StatefulSet.CurrentReplicas
+ lastTimestamp, err := f(label.AnnTiKVLastAutoScalingTimestamp)
+ if err != nil {
+ return err
+ }
+ tac.Status.TiKV.LastAutoScalingTimestamp = &lastTimestamp
+ } else {
+ tac.Status.TiKV = nil
}
if tac.Spec.TiDB != nil {
tac.Status.TiDB.CurrentReplicas = oldTc.Status.TiDB.StatefulSet.CurrentReplicas
+ lastTimestamp, err := f(label.AnnTiDBLastAutoScalingTimestamp)
+ if err != nil {
+ return err
+ }
+ tac.Status.TiDB.LastAutoScalingTimestamp = &lastTimestamp
+ } else {
+ tac.Status.TiDB = nil
}
return am.updateTidbClusterAutoScaler(tac)
}
From 60a21184fcf78c1f8e632316a911b29354cbe392 Mon Sep 17 00:00:00 2001
From: Song Gao <2695690803@qq.com>
Date: Wed, 15 Apr 2020 13:35:00 +0800
Subject: [PATCH 8/9] address the comment
---
pkg/autoscaler/autoscaler/autoscaler_manager.go | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/pkg/autoscaler/autoscaler/autoscaler_manager.go b/pkg/autoscaler/autoscaler/autoscaler_manager.go
index e0ed8b9577f..3c53cf62874 100644
--- a/pkg/autoscaler/autoscaler/autoscaler_manager.go
+++ b/pkg/autoscaler/autoscaler/autoscaler_manager.go
@@ -152,7 +152,9 @@ func (am *autoScalerManager) updateAutoScaling(oldTc *v1alpha1.TidbCluster,
if err != nil {
return err
}
- tac.Status.TiKV.LastAutoScalingTimestamp = &lastTimestamp
+ if len(lastTimestamp) > 0 {
+ tac.Status.TiKV.LastAutoScalingTimestamp = &lastTimestamp
+ }
} else {
tac.Status.TiKV = nil
}
@@ -162,7 +164,9 @@ func (am *autoScalerManager) updateAutoScaling(oldTc *v1alpha1.TidbCluster,
if err != nil {
return err
}
- tac.Status.TiDB.LastAutoScalingTimestamp = &lastTimestamp
+ if len(lastTimestamp) > 0 {
+ tac.Status.TiDB.LastAutoScalingTimestamp = &lastTimestamp
+ }
} else {
tac.Status.TiDB = nil
}
From d5ba990de27b63ae16a82a1f5a7cbfffd375dcb1 Mon Sep 17 00:00:00 2001
From: Song Gao <2695690803@qq.com>
Date: Wed, 15 Apr 2020 15:18:37 +0800
Subject: [PATCH 9/9] use metav1.Time
---
docs/api-references/docs.md | 4 +++-
manifests/crd.yaml | 12 ++++++++----
pkg/apis/pingcap/v1alpha1/openapi_generated.go | 15 ++++++---------
.../v1alpha1/tidbclusterautoscaler_types.go | 2 +-
.../pingcap/v1alpha1/zz_generated.deepcopy.go | 3 +--
pkg/autoscaler/autoscaler/autoscaler_manager.go | 17 +++++++++--------
6 files changed, 28 insertions(+), 25 deletions(-)
diff --git a/docs/api-references/docs.md b/docs/api-references/docs.md
index b4f075392fe..84e54e337e8 100644
--- a/docs/api-references/docs.md
+++ b/docs/api-references/docs.md
@@ -2413,7 +2413,9 @@ int32
lastAutoScalingTimestamp
-string
+
+Kubernetes meta/v1.Time
+
|
diff --git a/manifests/crd.yaml b/manifests/crd.yaml
index 73ef04d3b1f..8945edfa9c3 100644
--- a/manifests/crd.yaml
+++ b/manifests/crd.yaml
@@ -10781,8 +10781,10 @@ spec:
format: int32
type: integer
lastAutoScalingTimestamp:
- description: LastAutoScalingTimestamp describes the last auto-scaling
- timestamp for the component(tidb/tikv)
+ description: Time is a wrapper around time.Time which supports correct
+ marshaling to YAML and JSON. Wrappers are provided for many of
+ the factory methods that the time package offers.
+ format: date-time
type: string
metrics:
description: MetricsStatusList describes the metrics status in the
@@ -10826,8 +10828,10 @@ spec:
format: int32
type: integer
lastAutoScalingTimestamp:
- description: LastAutoScalingTimestamp describes the last auto-scaling
- timestamp for the component(tidb/tikv)
+ description: Time is a wrapper around time.Time which supports correct
+ marshaling to YAML and JSON. Wrappers are provided for many of
+ the factory methods that the time package offers.
+ format: date-time
type: string
metrics:
description: MetricsStatusList describes the metrics status in the
diff --git a/pkg/apis/pingcap/v1alpha1/openapi_generated.go b/pkg/apis/pingcap/v1alpha1/openapi_generated.go
index e1a4f6e13d4..2e6bdb3af9c 100644
--- a/pkg/apis/pingcap/v1alpha1/openapi_generated.go
+++ b/pkg/apis/pingcap/v1alpha1/openapi_generated.go
@@ -921,8 +921,7 @@ func schema_pkg_apis_pingcap_v1alpha1_BasicAutoScalerStatus(ref common.Reference
"lastAutoScalingTimestamp": {
SchemaProps: spec.SchemaProps{
Description: "LastAutoScalingTimestamp describes the last auto-scaling timestamp for the component(tidb/tikv)",
- Type: []string{"string"},
- Format: "",
+ Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"),
},
},
},
@@ -930,7 +929,7 @@ func schema_pkg_apis_pingcap_v1alpha1_BasicAutoScalerStatus(ref common.Reference
},
},
Dependencies: []string{
- "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.MetricsStatus"},
+ "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.MetricsStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.Time"},
}
}
@@ -6860,8 +6859,7 @@ func schema_pkg_apis_pingcap_v1alpha1_TidbAutoScalerStatus(ref common.ReferenceC
"lastAutoScalingTimestamp": {
SchemaProps: spec.SchemaProps{
Description: "LastAutoScalingTimestamp describes the last auto-scaling timestamp for the component(tidb/tikv)",
- Type: []string{"string"},
- Format: "",
+ Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"),
},
},
},
@@ -6869,7 +6867,7 @@ func schema_pkg_apis_pingcap_v1alpha1_TidbAutoScalerStatus(ref common.ReferenceC
},
},
Dependencies: []string{
- "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.MetricsStatus"},
+ "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.MetricsStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.Time"},
}
}
@@ -7883,8 +7881,7 @@ func schema_pkg_apis_pingcap_v1alpha1_TikvAutoScalerStatus(ref common.ReferenceC
"lastAutoScalingTimestamp": {
SchemaProps: spec.SchemaProps{
Description: "LastAutoScalingTimestamp describes the last auto-scaling timestamp for the component(tidb/tikv)",
- Type: []string{"string"},
- Format: "",
+ Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"),
},
},
},
@@ -7892,7 +7889,7 @@ func schema_pkg_apis_pingcap_v1alpha1_TikvAutoScalerStatus(ref common.ReferenceC
},
},
Dependencies: []string{
- "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.MetricsStatus"},
+ "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.MetricsStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.Time"},
}
}
diff --git a/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go b/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go
index 06d38230e53..e38a570fa1a 100644
--- a/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go
+++ b/pkg/apis/pingcap/v1alpha1/tidbclusterautoscaler_types.go
@@ -185,7 +185,7 @@ type BasicAutoScalerStatus struct {
RecommendedReplicas *int32 `json:"recommendedReplicas,omitempty"`
// LastAutoScalingTimestamp describes the last auto-scaling timestamp for the component(tidb/tikv)
// +optional
- LastAutoScalingTimestamp *string `json:"lastAutoScalingTimestamp,omitempty"`
+ LastAutoScalingTimestamp *metav1.Time `json:"lastAutoScalingTimestamp,omitempty"`
}
// +k8s:openapi-gen=true
diff --git a/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go
index 5041ee236dd..d2ddaf3da9d 100644
--- a/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go
@@ -399,8 +399,7 @@ func (in *BasicAutoScalerStatus) DeepCopyInto(out *BasicAutoScalerStatus) {
}
if in.LastAutoScalingTimestamp != nil {
in, out := &in.LastAutoScalingTimestamp, &out.LastAutoScalingTimestamp
- *out = new(string)
- **out = **in
+ *out = (*in).DeepCopy()
}
return
}
diff --git a/pkg/autoscaler/autoscaler/autoscaler_manager.go b/pkg/autoscaler/autoscaler/autoscaler_manager.go
index 3c53cf62874..6fffa03eb35 100644
--- a/pkg/autoscaler/autoscaler/autoscaler_manager.go
+++ b/pkg/autoscaler/autoscaler/autoscaler_manager.go
@@ -133,17 +133,18 @@ func (am *autoScalerManager) updateAutoScaling(oldTc *v1alpha1.TidbCluster,
if tac.Annotations == nil {
tac.Annotations = map[string]string{}
}
- f := func(key string) (string, error) {
+ f := func(key string) (*time.Time, error) {
v, ok := tac.Annotations[key]
if ok {
ts, err := strconv.ParseInt(v, 10, 64)
if err != nil {
klog.Errorf("failed to convert label[%s] key to int64, err:%v", key, err)
- return "", err
+ return nil, err
}
- return time.Unix(ts, 0).Format(time.RFC3339), nil
+ t := time.Unix(ts, 0)
+ return &t, nil
}
- return "", nil
+ return nil, nil
}
if tac.Spec.TiKV != nil {
@@ -152,8 +153,8 @@ func (am *autoScalerManager) updateAutoScaling(oldTc *v1alpha1.TidbCluster,
if err != nil {
return err
}
- if len(lastTimestamp) > 0 {
- tac.Status.TiKV.LastAutoScalingTimestamp = &lastTimestamp
+ if lastTimestamp != nil {
+ tac.Status.TiKV.LastAutoScalingTimestamp = &metav1.Time{Time: *lastTimestamp}
}
} else {
tac.Status.TiKV = nil
@@ -164,8 +165,8 @@ func (am *autoScalerManager) updateAutoScaling(oldTc *v1alpha1.TidbCluster,
if err != nil {
return err
}
- if len(lastTimestamp) > 0 {
- tac.Status.TiDB.LastAutoScalingTimestamp = &lastTimestamp
+ if lastTimestamp != nil {
+ tac.Status.TiDB.LastAutoScalingTimestamp = &metav1.Time{Time: *lastTimestamp}
}
} else {
tac.Status.TiDB = nil
|