From 9e0ace9c8e37c9037e2d671b570b3fd3089a884f Mon Sep 17 00:00:00 2001 From: pingcap-github-bot Date: Tue, 3 Mar 2020 12:20:39 +0800 Subject: [PATCH] Fix defaulting bug (#1845) (#1847) --- .../v1alpha1/defaulting/tidbcluster.go | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/pkg/apis/pingcap/v1alpha1/defaulting/tidbcluster.go b/pkg/apis/pingcap/v1alpha1/defaulting/tidbcluster.go index c6a1701c75..6704bb2d55 100644 --- a/pkg/apis/pingcap/v1alpha1/defaulting/tidbcluster.go +++ b/pkg/apis/pingcap/v1alpha1/defaulting/tidbcluster.go @@ -54,8 +54,10 @@ func setTidbSpecDefault(tc *v1alpha1.TidbCluster) { if tc.Spec.TiDB.BaseImage == "" { tc.Spec.TiDB.BaseImage = defaultTiDBImage } - if tc.Spec.TiDB.Config == nil { - tc.Spec.TiDB.Config = &v1alpha1.TiDBConfig{} + if len(tc.Spec.Version) > 0 || tc.Spec.TiDB.Version != nil { + if tc.Spec.TiDB.Config == nil { + tc.Spec.TiDB.Config = &v1alpha1.TiDBConfig{} + } } } @@ -63,8 +65,10 @@ func setTikvSpecDefault(tc *v1alpha1.TidbCluster) { if tc.Spec.TiKV.Config == nil { tc.Spec.TiKV.Config = &v1alpha1.TiKVConfig{} } - if tc.Spec.TiKV.BaseImage == "" { - tc.Spec.TiKV.BaseImage = defaultTiKVImage + if len(tc.Spec.Version) > 0 || tc.Spec.TiKV.Version != nil { + if tc.Spec.TiKV.BaseImage == "" { + tc.Spec.TiKV.BaseImage = defaultTiKVImage + } } } @@ -72,13 +76,17 @@ func setPdSpecDefault(tc *v1alpha1.TidbCluster) { if tc.Spec.PD.Config == nil { tc.Spec.PD.Config = &v1alpha1.PDConfig{} } - if tc.Spec.PD.BaseImage == "" { - tc.Spec.PD.BaseImage = defaultPDImage + if len(tc.Spec.Version) > 0 || tc.Spec.PD.Version != nil { + if tc.Spec.PD.BaseImage == "" { + tc.Spec.PD.BaseImage = defaultPDImage + } } } func setPumpSpecDefault(tc *v1alpha1.TidbCluster) { - if tc.Spec.Pump.BaseImage == "" { - tc.Spec.Pump.BaseImage = defaultBinlogImage + if len(tc.Spec.Version) > 0 || tc.Spec.Pump.Version != nil { + if tc.Spec.Pump.BaseImage == "" { + tc.Spec.Pump.BaseImage = defaultBinlogImage + } } }