Skip to content

Commit

Permalink
revise compare tc
Browse files Browse the repository at this point in the history
  • Loading branch information
Song Gao committed Feb 20, 2020
1 parent 14d1208 commit b115a79
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/autoscaler/autoscaler/autoscaler_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
v1alpha1listers "github.com/pingcap/tidb-operator/pkg/client/listers/pingcap/v1alpha1"
"github.com/pingcap/tidb-operator/pkg/controller"
promClient "github.com/prometheus/client_golang/api"
apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
Expand Down Expand Up @@ -97,18 +96,22 @@ func (am *autoScalerManager) syncAutoScaling(tc *v1alpha1.TidbCluster, tac *v1al
return err
}
defaultTAC(tac)
oldTikvReplicas := tc.Spec.TiKV.Replicas
if err := am.syncTiKV(tc, tac, c); err != nil {
tc.Spec.TiKV.Replicas = oldTikvReplicas
klog.Errorf("tac[%s/%s] tikv sync failed, continue to sync next, err:%v", tac.Namespace, tac.Name, err)
}
oldTidbReplicas := tc.Spec.TiDB.Replicas
if err := am.syncTiDB(tc, tac, c); err != nil {
tc.Spec.TiDB.Replicas = oldTidbReplicas
klog.Errorf("tac[%s/%s] tidb sync failed, continue to sync next, err:%v", tac.Namespace, tac.Name, err)
}
klog.Infof("tc[%s/%s]'s tac[%s/%s] synced", tc.Namespace, tc.Name, tac.Namespace, tac.Name)
return nil
}

func (am *autoScalerManager) syncTidbClusterReplicas(tc *v1alpha1.TidbCluster, oldTc *v1alpha1.TidbCluster) error {
if apiequality.Semantic.DeepEqual(tc, oldTc) {
if tc.Spec.TiDB.Replicas == oldTc.Spec.TiDB.Replicas && tc.Spec.TiKV.Replicas == oldTc.Spec.TiKV.Replicas {
return nil
}
newTc := tc.DeepCopy()
Expand Down

0 comments on commit b115a79

Please sign in to comment.