diff --git a/pkg/autoscaler/autoscaler/autoscaler_manager.go b/pkg/autoscaler/autoscaler/autoscaler_manager.go index 6fffa03eb3..34f781a4c7 100644 --- a/pkg/autoscaler/autoscaler/autoscaler_manager.go +++ b/pkg/autoscaler/autoscaler/autoscaler_manager.go @@ -148,7 +148,9 @@ func (am *autoScalerManager) updateAutoScaling(oldTc *v1alpha1.TidbCluster, } if tac.Spec.TiKV != nil { - tac.Status.TiKV.CurrentReplicas = oldTc.Status.TiKV.StatefulSet.CurrentReplicas + if oldTc.Status.TiKV.StatefulSet != nil { + tac.Status.TiKV.CurrentReplicas = oldTc.Status.TiKV.StatefulSet.CurrentReplicas + } lastTimestamp, err := f(label.AnnTiKVLastAutoScalingTimestamp) if err != nil { return err @@ -160,7 +162,9 @@ func (am *autoScalerManager) updateAutoScaling(oldTc *v1alpha1.TidbCluster, tac.Status.TiKV = nil } if tac.Spec.TiDB != nil { - tac.Status.TiDB.CurrentReplicas = oldTc.Status.TiDB.StatefulSet.CurrentReplicas + if oldTc.Status.TiDB.StatefulSet != nil { + tac.Status.TiDB.CurrentReplicas = oldTc.Status.TiDB.StatefulSet.CurrentReplicas + } lastTimestamp, err := f(label.AnnTiDBLastAutoScalingTimestamp) if err != nil { return err