From bbc2f49c9ae8fe030c9723c8b27c31c39fa51bc6 Mon Sep 17 00:00:00 2001 From: xiaojingchen Date: Tue, 9 Jul 2019 17:05:22 +0800 Subject: [PATCH 1/4] remove storeLabels --- .../tidb-cluster/templates/config/_pd-config.tpl | 4 ---- charts/tidb-cluster/templates/tidb-cluster.yaml | 10 ---------- charts/tidb-cluster/values.yaml | 10 ---------- go.mod | 3 ++- go.sum | 2 ++ pkg/apis/pingcap.com/v1alpha1/types.go | 1 - .../pingcap.com/v1alpha1/zz_generated.deepcopy.go | 5 ----- pkg/manager/member/tikv_member_manager.go | 12 +++++++++++- tests/actions.go | 7 ------- tests/cmd/e2e/main.go | 8 ++++---- tests/cmd/stability/stability.go | 2 +- tests/util.go | 15 ++++----------- 12 files changed, 24 insertions(+), 55 deletions(-) diff --git a/charts/tidb-cluster/templates/config/_pd-config.tpl b/charts/tidb-cluster/templates/config/_pd-config.tpl index 9a644e9b081..ea5d044f5a4 100644 --- a/charts/tidb-cluster/templates/config/_pd-config.tpl +++ b/charts/tidb-cluster/templates/config/_pd-config.tpl @@ -82,11 +82,7 @@ max-replicas = {{ .Values.pd.maxReplicas }} # The placement priorities is implied by the order of label keys. # For example, ["zone", "rack"] means that we should place replicas to # different zones first, then to different racks if we don't have enough zones. -{{- if .Values.tikv.storeLabels }} -location-labels = {{ toJson .Values.tikv.storeLabels }} -{{- else }} location-labels = ["region", "zone", "rack", "host"] -{{- end }} [label-property] # Do not assign region leaders to stores that have these tags. diff --git a/charts/tidb-cluster/templates/tidb-cluster.yaml b/charts/tidb-cluster/templates/tidb-cluster.yaml index 7e6484a3685..a2d94ea3555 100644 --- a/charts/tidb-cluster/templates/tidb-cluster.yaml +++ b/charts/tidb-cluster/templates/tidb-cluster.yaml @@ -67,16 +67,6 @@ spec: annotations: {{ toYaml .Values.tikv.annotations | indent 6 }} {{- end }} - {{- if .Values.tikv.storeLabels }} - storeLabels: -{{ toYaml .Values.tikv.storeLabels | indent 4 }} - {{- else }} - storeLabels: - - region - - zone - - rack - - host - {{- end }} tidb: replicas: {{ .Values.tidb.replicas }} image: {{ .Values.tidb.image }} diff --git a/charts/tidb-cluster/values.yaml b/charts/tidb-cluster/values.yaml index 49626182266..2c8144ad0b5 100644 --- a/charts/tidb-cluster/values.yaml +++ b/charts/tidb-cluster/values.yaml @@ -192,16 +192,6 @@ tikv: # effect: "NoSchedule" annotations: {} - ## storeLabels is used to define store label keys - ## The label keys specified the location of a store. - ## In order to use the location awareness feature of TiKV, users have to label their k8s nodes with the same labels. - ## Note: current can not support these labels contains "/" - ## The placement priorities is implied by the order of label keys. - ## For example, ["zone", "rack"] means that we should place replicas to - ## different zones first, then to different racks if we don't have enough zones. - ## default value is ["region", "zone", "rack", "host"] - ## storeLabels: ["region", "zone", "rack", "host"] - # block-cache used to cache uncompressed blocks, big block-cache can speed up read. # in normal cases should tune to 30%-50% tikv.resources.limits.memory # defaultcfBlockCacheSize: "1GB" diff --git a/go.mod b/go.mod index 18e20d40b64..08836a34854 100644 --- a/go.mod +++ b/go.mod @@ -104,6 +104,7 @@ require ( golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421 // indirect golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 // indirect golang.org/x/tools v0.0.0-20190405180640-052fc3cfdbc2 // indirect + gonum.org/v1/netlib v0.0.0-20190331212654-76723241ea4e // indirect google.golang.org/genproto v0.0.0-20180731170733-daca94659cb5 // indirect google.golang.org/grpc v1.12.0 // indirect gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect @@ -121,7 +122,7 @@ require ( k8s.io/apiserver v0.0.0-20190118115647-a748535592ba k8s.io/cli-runtime v0.0.0-20190118125240-caee4253d968 k8s.io/client-go v2.0.0-alpha.0.0.20190115164855-701b91367003+incompatible - k8s.io/code-generator v0.0.0-20190612125529-c522cb6c26aa + k8s.io/code-generator v0.0.0-20181128191024-b1289fc74931 k8s.io/gengo v0.0.0-20190327210449-e17681d19d3a // indirect; indirec k8s.io/klog v0.3.1 k8s.io/kube-openapi v0.0.0-20190320154901-5e45bb682580 // indirect diff --git a/go.sum b/go.sum index b590cbe18f5..53efe1b82d7 100644 --- a/go.sum +++ b/go.sum @@ -301,6 +301,8 @@ k8s.io/cli-runtime v0.0.0-20190118125240-caee4253d968 h1:VXLj8aMvJEo14Utv+knJDs0 k8s.io/cli-runtime v0.0.0-20190118125240-caee4253d968/go.mod h1:qWnH3/b8sp/l7EvlDh7ulDU3UWA4P4N1NFbEEP791tM= k8s.io/client-go v2.0.0-alpha.0.0.20190115164855-701b91367003+incompatible h1:Qw/ADzXV2yX+39UUCwNcZmdNS4+sR+V2Jf9NBdZWlQg= k8s.io/client-go v2.0.0-alpha.0.0.20190115164855-701b91367003+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s= +k8s.io/code-generator v0.0.0-20181128191024-b1289fc74931 h1:5nlNOG+ShM9gcSivU8/IEhrANa/ljMMEJ1sw86/eFzQ= +k8s.io/code-generator v0.0.0-20181128191024-b1289fc74931/go.mod h1:MYiN+ZJZ9HkETbgVZdWw2AsuAi9PZ4V80cwfuf2axe8= k8s.io/code-generator v0.0.0-20190612125529-c522cb6c26aa h1:R/ZQEUP8jVryCMdJDSiHqx00/u9k2oRt0LEZq/qK+tE= k8s.io/code-generator v0.0.0-20190612125529-c522cb6c26aa/go.mod h1:G8bQwmHm2eafm5bgtX67XDZQ8CWKSGu9DekI+yN4Y5I= k8s.io/gengo v0.0.0-20190116091435-f8a0810f38af/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= diff --git a/pkg/apis/pingcap.com/v1alpha1/types.go b/pkg/apis/pingcap.com/v1alpha1/types.go index 402ceb449bb..a539b4c123f 100644 --- a/pkg/apis/pingcap.com/v1alpha1/types.go +++ b/pkg/apis/pingcap.com/v1alpha1/types.go @@ -144,7 +144,6 @@ type TiKVSpec struct { StorageClassName string `json:"storageClassName,omitempty"` Tolerations []corev1.Toleration `json:"tolerations,omitempty"` Annotations map[string]string `json:"annotations,omitempty"` - StoreLabels []string `json:"storeLabels,omitempty"` } // TiKVPromGatewaySpec runs as a sidecar with TiKVSpec diff --git a/pkg/apis/pingcap.com/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/pingcap.com/v1alpha1/zz_generated.deepcopy.go index df77c36db6a..1bf3b6d605d 100644 --- a/pkg/apis/pingcap.com/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/pingcap.com/v1alpha1/zz_generated.deepcopy.go @@ -388,11 +388,6 @@ func (in *TiKVSpec) DeepCopyInto(out *TiKVSpec) { (*out)[key] = val } } - if in.StoreLabels != nil { - in, out := &in.StoreLabels, &out.StoreLabels - *out = make([]string, len(*in)) - copy(*out, *in) - } return } diff --git a/pkg/manager/member/tikv_member_manager.go b/pkg/manager/member/tikv_member_manager.go index 114f1593596..8b7c50dbe9d 100644 --- a/pkg/manager/member/tikv_member_manager.go +++ b/pkg/manager/member/tikv_member_manager.go @@ -524,6 +524,16 @@ func (tkmm *tikvMemberManager) setStoreLabelsForTiKV(tc *v1alpha1.TidbCluster) ( return setCount, err } + config, err := pdCli.GetConfig() + if err != nil { + return setCount, err + } + + locationLabels := []string(config.Replication.LocationLabels) + if locationLabels == nil { + return setCount, nil + } + for _, store := range storesInfo.Stores { status := tkmm.getTiKVStore(store) if status == nil { @@ -537,7 +547,7 @@ func (tkmm *tikvMemberManager) setStoreLabelsForTiKV(tc *v1alpha1.TidbCluster) ( } nodeName := pod.Spec.NodeName - ls, err := tkmm.getNodeLabels(nodeName, tc.Spec.TiKV.StoreLabels) + ls, err := tkmm.getNodeLabels(nodeName, locationLabels) if err != nil || len(ls) == 0 { glog.Warningf("node: [%s] has no node labels, skipping set store labels for Pod: [%s/%s]", nodeName, ns, podName) continue diff --git a/tests/actions.go b/tests/actions.go index 69e03f8b034..a69b1168713 100644 --- a/tests/actions.go +++ b/tests/actions.go @@ -710,13 +710,6 @@ func (oa *operatorActions) CheckTidbClusterStatus(info *TidbClusterConfig) error return false, nil } - glog.V(4).Infof("check store labels") - if b, err := oa.storeLabelsIsSet(tc, info.TopologyKey); !b && err == nil { - return false, nil - } else if err != nil { - return false, err - } - glog.V(4).Infof("check tidb cluster begin passwordIsSet") if b, err := oa.passwordIsSet(info); !b && err == nil { return false, nil diff --git a/tests/cmd/e2e/main.go b/tests/cmd/e2e/main.go index 07e8f97fa9c..8c14d6fd88d 100644 --- a/tests/cmd/e2e/main.go +++ b/tests/cmd/e2e/main.go @@ -112,7 +112,7 @@ func main() { RawSize: 1, }, TopologyKey: topologyKey, - SubValues: fmt.Sprintf("%s", tests.GetAffinityConfigOrDie(name1, name1, topologyKey, []string{topologyKey})), + SubValues: fmt.Sprintf("%s", tests.GetAffinityConfigOrDie(name1, name1, topologyKey)), EnableConfigMapRollout: true, PDMaxReplicas: 3, TiKVGrpcConcurrency: 4, @@ -156,7 +156,7 @@ func main() { RawSize: 1, }, TopologyKey: topologyKey, - SubValues: fmt.Sprintf("%s", tests.GetAffinityConfigOrDie(name2, name2, topologyKey, []string{topologyKey})), + SubValues: fmt.Sprintf("%s", tests.GetAffinityConfigOrDie(name2, name2, topologyKey)), EnableConfigMapRollout: false, PDMaxReplicas: 3, TiKVGrpcConcurrency: 4, @@ -181,7 +181,7 @@ func main() { }, TopologyKey: topologyKey, - SubValues: fmt.Sprintf("%s", tests.GetAffinityConfigOrDie(name3, name2, topologyKey, []string{topologyKey})), + SubValues: fmt.Sprintf("%s", tests.GetAffinityConfigOrDie(name3, name2, topologyKey)), }, } @@ -340,7 +340,7 @@ func main() { restoreClusterInfo.ClusterName = restoreClusterInfo.ClusterName + "-other" restoreClusterInfo.InitSecretName = fmt.Sprintf("%s-set-secret", restoreClusterInfo.ClusterName) restoreClusterInfo.BackupSecretName = fmt.Sprintf("%s-backup-secret", restoreClusterInfo.ClusterName) - restoreClusterInfo.SubValues = fmt.Sprintf("%s", tests.GetAffinityConfigOrDie(restoreClusterInfo.ClusterName, restoreClusterInfo.Namespace, topologyKey, []string{topologyKey})) + restoreClusterInfo.SubValues = fmt.Sprintf("%s", tests.GetAffinityConfigOrDie(restoreClusterInfo.ClusterName, restoreClusterInfo.Namespace, topologyKey)) if err = oa.CleanTidbCluster(restoreClusterInfo); err != nil { glog.Fatal(err) diff --git a/tests/cmd/stability/stability.go b/tests/cmd/stability/stability.go index 37ae08a79e5..af662690371 100644 --- a/tests/cmd/stability/stability.go +++ b/tests/cmd/stability/stability.go @@ -70,6 +70,6 @@ func newTidbClusterConfig(ns, clusterName string) *tests.TidbClusterConfig { TiKVGrpcConcurrency: 4, TiDBTokenLimit: 1000, PDLogLevel: "info", - SubValues: tests.GetAffinityConfigOrDie(clusterName, ns, topologyKey, []string{topologyKey}), + SubValues: tests.GetAffinityConfigOrDie(clusterName, ns, topologyKey), } } diff --git a/tests/util.go b/tests/util.go index adc05bd6841..88a56ffd11c 100644 --- a/tests/util.go +++ b/tests/util.go @@ -89,12 +89,6 @@ func GetPodsByLabels(kubeCli kubernetes.Interface, node string, lables map[strin } var affinityTemp string = `{{.Kind}}: -{{ $length := len .StoreLabels}} {{ if or (not .StoreLabels) (eq $length 0)}} -{{else if eq .Kind "tikv"}} - storeLabels: -{{range .StoreLabels}} - {{.}} -{{end}} -{{end}} affinity: podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: @@ -115,27 +109,26 @@ type AffinityInfo struct { Weight int Namespace string TopologyKey string - StoreLabels []string } -func GetAffinityConfigOrDie(clusterName, namespace, topologyKey string, storeLabels []string) string { +func GetAffinityConfigOrDie(clusterName, namespace, topologyKey string) string { temp, err := template.New("dt-affinity").Parse(affinityTemp) if err != nil { slack.NotifyAndPanic(err) } pdbuff := new(bytes.Buffer) - err = temp.Execute(pdbuff, &AffinityInfo{ClusterName: clusterName, Kind: "pd", Weight: 50, Namespace: namespace, TopologyKey: topologyKey, StoreLabels: storeLabels}) + err = temp.Execute(pdbuff, &AffinityInfo{ClusterName: clusterName, Kind: "pd", Weight: 50, Namespace: namespace, TopologyKey: topologyKey}) if err != nil { slack.NotifyAndPanic(err) } tikvbuff := new(bytes.Buffer) - err = temp.Execute(tikvbuff, &AffinityInfo{ClusterName: clusterName, Kind: "tikv", Weight: 50, Namespace: namespace, TopologyKey: topologyKey, StoreLabels: storeLabels}) + err = temp.Execute(tikvbuff, &AffinityInfo{ClusterName: clusterName, Kind: "tikv", Weight: 50, Namespace: namespace, TopologyKey: topologyKey}) if err != nil { slack.NotifyAndPanic(err) } tidbbuff := new(bytes.Buffer) - err = temp.Execute(tidbbuff, &AffinityInfo{ClusterName: clusterName, Kind: "tidb", Weight: 50, Namespace: namespace, TopologyKey: topologyKey, StoreLabels: storeLabels}) + err = temp.Execute(tidbbuff, &AffinityInfo{ClusterName: clusterName, Kind: "tidb", Weight: 50, Namespace: namespace, TopologyKey: topologyKey}) if err != nil { slack.NotifyAndPanic(err) } From 0178bf16c26112d50c407b45691caec55edd3b9e Mon Sep 17 00:00:00 2001 From: xiaojingchen Date: Mon, 15 Jul 2019 15:52:50 +0800 Subject: [PATCH 2/4] fix unit test --- .../member/tikv_member_manager_test.go | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/pkg/manager/member/tikv_member_manager_test.go b/pkg/manager/member/tikv_member_manager_test.go index 0e2afa6d9df..1443ede2df8 100644 --- a/pkg/manager/member/tikv_member_manager_test.go +++ b/pkg/manager/member/tikv_member_manager_test.go @@ -19,6 +19,10 @@ import ( "testing" "time" + "github.com/pingcap/pd/pkg/typeutil" + + "github.com/pingcap/pd/server" + . "github.com/onsi/gomega" "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/tidb-operator/pkg/apis/pingcap.com/v1alpha1" @@ -72,7 +76,13 @@ func TestTiKVMemberManagerSyncCreate(t *testing.T) { } tkmm, fakeSetControl, fakeSvcControl, pdClient, _, _ := newFakeTiKVMemberManager(tc) - + pdClient.AddReaction(pdapi.GetConfigActionType, func(action *pdapi.Action) (interface{}, error) { + return &server.Config{ + Replication: server.ReplicationConfig{ + LocationLabels: typeutil.StringSlice{"region", "zone", "rack", "host"}, + }, + }, nil + }) if test.errWhenGetStores { pdClient.AddReaction(pdapi.GetStoresActionType, func(action *pdapi.Action) (interface{}, error) { return nil, fmt.Errorf("failed to get stores from tikv cluster") @@ -221,6 +231,13 @@ func TestTiKVMemberManagerSyncUpdate(t *testing.T) { tcName := tc.Name tkmm, fakeSetControl, fakeSvcControl, pdClient, _, _ := newFakeTiKVMemberManager(tc) + pdClient.AddReaction(pdapi.GetConfigActionType, func(action *pdapi.Action) (interface{}, error) { + return &server.Config{ + Replication: server.ReplicationConfig{ + LocationLabels: typeutil.StringSlice{"region", "zone", "rack", "host"}, + }, + }, nil + }) if test.errWhenGetStores { pdClient.AddReaction(pdapi.GetStoresActionType, func(action *pdapi.Action) (interface{}, error) { return nil, fmt.Errorf("failed to get stores from pd cluster") @@ -489,9 +506,14 @@ func TestTiKVMemberManagerSetStoreLabelsForTiKV(t *testing.T) { } testFn := func(test *testcase, t *testing.T) { tc := newTidbClusterForPD() - tc.Spec.TiKV.StoreLabels = []string{"region", "zone", "rack"} pmm, _, _, pdClient, podIndexer, nodeIndexer := newFakeTiKVMemberManager(tc) - + pdClient.AddReaction(pdapi.GetConfigActionType, func(action *pdapi.Action) (interface{}, error) { + return &server.Config{ + Replication: server.ReplicationConfig{ + LocationLabels: typeutil.StringSlice{"region", "zone", "rack", "host"}, + }, + }, nil + }) if test.errWhenGetStores { pdClient.AddReaction(pdapi.GetStoresActionType, func(action *pdapi.Action) (interface{}, error) { return nil, fmt.Errorf("failed to get stores") From 791e83bc531dca7d8056235f85ab697cb9bb15b8 Mon Sep 17 00:00:00 2001 From: xiaojingchen Date: Wed, 17 Jul 2019 20:41:40 +0800 Subject: [PATCH 3/4] fix error --- .../templates/config/_pd-config.tpl | 91 ------------------- charts/tidb-cluster/values.yaml | 31 ------- go.mod | 3 +- go.sum | 2 - .../member/tikv_member_manager_test.go | 6 +- 5 files changed, 3 insertions(+), 130 deletions(-) delete mode 100644 charts/tidb-cluster/templates/config/_pd-config.tpl diff --git a/charts/tidb-cluster/templates/config/_pd-config.tpl b/charts/tidb-cluster/templates/config/_pd-config.tpl deleted file mode 100644 index ea5d044f5a4..00000000000 --- a/charts/tidb-cluster/templates/config/_pd-config.tpl +++ /dev/null @@ -1,91 +0,0 @@ -# PD Configuration. - -name = "pd" -data-dir = "default.pd" - -client-urls = "http://127.0.0.1:2379" -# if not set, use ${client-urls} -advertise-client-urls = "" - -peer-urls = "http://127.0.0.1:2380" -# if not set, use ${peer-urls} -advertise-peer-urls = "" - -initial-cluster = "" -initial-cluster-state = "" - -lease = 3 -tso-save-interval = "3s" - -namespace-classifier = "table" - -enable-prevote = true - -[security] -# Path of file that contains list of trusted SSL CAs. if set, following four settings shouldn't be empty -cacert-path = "" -# Path of file that contains X509 certificate in PEM format. -cert-path = "" -# Path of file that contains X509 key in PEM format. -key-path = "" - -[log] -level = {{ .Values.pd.logLevel | default "info" | quote }} - -# log format, one of json, text, console -#format = "text" - -# disable automatic timestamps in output -#disable-timestamp = false - -# file logging -[log.file] -#filename = "" -# max log file size in MB -#max-size = 300 -# max log file keep days -#max-days = 28 -# maximum number of old log files to retain -#max-backups = 7 -# rotate log by day -#log-rotate = true - -[metric] -# prometheus client push interval, set "0s" to disable prometheus. -interval = "15s" -# prometheus pushgateway address, leaves it empty will disable prometheus. -address = "" - -[schedule] -max-merge-region-size = 0 -max-merge-region-keys = 0 -split-merge-interval = "1h" -max-snapshot-count = 3 -max-pending-peer-count = 16 -max-store-down-time = "{{ .Values.pd.maxStoreDownTime }}" -leader-schedule-limit = 4 -region-schedule-limit = 4 -replica-schedule-limit = 8 -merge-schedule-limit = 8 -tolerant-size-ratio = 5.0 - -# customized schedulers, the format is as below -# if empty, it will use balance-leader, balance-region, hot-region as default -# [[schedule.schedulers]] -# type = "evict-leader" -# args = ["1"] - -[replication] -# The number of replicas for each region. -max-replicas = {{ .Values.pd.maxReplicas }} -# The label keys specified the location of a store. -# The placement priorities is implied by the order of label keys. -# For example, ["zone", "rack"] means that we should place replicas to -# different zones first, then to different racks if we don't have enough zones. -location-labels = ["region", "zone", "rack", "host"] - -[label-property] -# Do not assign region leaders to stores that have these tags. -# [[label-property.reject-leader]] -# key = "zone" -# value = "cn1 diff --git a/charts/tidb-cluster/values.yaml b/charts/tidb-cluster/values.yaml index 1e31e06c0b2..8ca19f84602 100644 --- a/charts/tidb-cluster/values.yaml +++ b/charts/tidb-cluster/values.yaml @@ -241,37 +241,6 @@ tikv: # effect: "NoSchedule" annotations: {} -<<<<<<< HEAD - # block-cache used to cache uncompressed blocks, big block-cache can speed up read. - # in normal cases should tune to 30%-50% tikv.resources.limits.memory - # defaultcfBlockCacheSize: "1GB" - - # in normal cases should tune to 10%-30% tikv.resources.limits.memory - # writecfBlockCacheSize: "256MB" - - # size of thread pool for high-priority/normal-priority/low-priority operations - # readpoolStorageConcurrency: 4 - - # Notice: if tikv.resources.limits.cpu > 8, default thread pool size for coprocessors - # will be set to tikv.resources.limits.cpu * 0.8. - # readpoolCoprocessorConcurrency: 8 - - # scheduler's worker pool size, should increase it in heavy write cases, - # also should less than total cpu cores. - # storageSchedulerWorkerPoolSize: 4 -======= - ## storeLabels is used to define store label keys - ## The label keys specified the location of a store. - ## In order to use the location awareness feature of TiKV, users have to label their k8s nodes with the same labels. - ## Note: current can not support these labels contains "/" - ## The placement priorities is implied by the order of label keys. - ## For example, ["zone", "rack"] means that we should place replicas to - ## different zones first, then to different racks if we don't have enough zones. - ## default value is ["region", "zone", "rack", "host"] - ## If you change the default value below, please do sync the change to pd.config.[replication].location-labels - ## storeLabels: ["region", "zone", "rack", "host"] ->>>>>>> master - tidb: # Please refer to https://github.com/pingcap/tidb/blob/master/config/config.toml.example for the default # tidb configurations(change to the tags of your tidb version), diff --git a/go.mod b/go.mod index 08836a34854..18e20d40b64 100644 --- a/go.mod +++ b/go.mod @@ -104,7 +104,6 @@ require ( golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421 // indirect golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 // indirect golang.org/x/tools v0.0.0-20190405180640-052fc3cfdbc2 // indirect - gonum.org/v1/netlib v0.0.0-20190331212654-76723241ea4e // indirect google.golang.org/genproto v0.0.0-20180731170733-daca94659cb5 // indirect google.golang.org/grpc v1.12.0 // indirect gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect @@ -122,7 +121,7 @@ require ( k8s.io/apiserver v0.0.0-20190118115647-a748535592ba k8s.io/cli-runtime v0.0.0-20190118125240-caee4253d968 k8s.io/client-go v2.0.0-alpha.0.0.20190115164855-701b91367003+incompatible - k8s.io/code-generator v0.0.0-20181128191024-b1289fc74931 + k8s.io/code-generator v0.0.0-20190612125529-c522cb6c26aa k8s.io/gengo v0.0.0-20190327210449-e17681d19d3a // indirect; indirec k8s.io/klog v0.3.1 k8s.io/kube-openapi v0.0.0-20190320154901-5e45bb682580 // indirect diff --git a/go.sum b/go.sum index 53efe1b82d7..b590cbe18f5 100644 --- a/go.sum +++ b/go.sum @@ -301,8 +301,6 @@ k8s.io/cli-runtime v0.0.0-20190118125240-caee4253d968 h1:VXLj8aMvJEo14Utv+knJDs0 k8s.io/cli-runtime v0.0.0-20190118125240-caee4253d968/go.mod h1:qWnH3/b8sp/l7EvlDh7ulDU3UWA4P4N1NFbEEP791tM= k8s.io/client-go v2.0.0-alpha.0.0.20190115164855-701b91367003+incompatible h1:Qw/ADzXV2yX+39UUCwNcZmdNS4+sR+V2Jf9NBdZWlQg= k8s.io/client-go v2.0.0-alpha.0.0.20190115164855-701b91367003+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s= -k8s.io/code-generator v0.0.0-20181128191024-b1289fc74931 h1:5nlNOG+ShM9gcSivU8/IEhrANa/ljMMEJ1sw86/eFzQ= -k8s.io/code-generator v0.0.0-20181128191024-b1289fc74931/go.mod h1:MYiN+ZJZ9HkETbgVZdWw2AsuAi9PZ4V80cwfuf2axe8= k8s.io/code-generator v0.0.0-20190612125529-c522cb6c26aa h1:R/ZQEUP8jVryCMdJDSiHqx00/u9k2oRt0LEZq/qK+tE= k8s.io/code-generator v0.0.0-20190612125529-c522cb6c26aa/go.mod h1:G8bQwmHm2eafm5bgtX67XDZQ8CWKSGu9DekI+yN4Y5I= k8s.io/gengo v0.0.0-20190116091435-f8a0810f38af/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= diff --git a/pkg/manager/member/tikv_member_manager_test.go b/pkg/manager/member/tikv_member_manager_test.go index 1443ede2df8..798fde31131 100644 --- a/pkg/manager/member/tikv_member_manager_test.go +++ b/pkg/manager/member/tikv_member_manager_test.go @@ -19,12 +19,10 @@ import ( "testing" "time" - "github.com/pingcap/pd/pkg/typeutil" - - "github.com/pingcap/pd/server" - . "github.com/onsi/gomega" "github.com/pingcap/kvproto/pkg/metapb" + "github.com/pingcap/pd/pkg/typeutil" + "github.com/pingcap/pd/server" "github.com/pingcap/tidb-operator/pkg/apis/pingcap.com/v1alpha1" "github.com/pingcap/tidb-operator/pkg/client/clientset/versioned/fake" informers "github.com/pingcap/tidb-operator/pkg/client/informers/externalversions" From 93f72eff3cf89abee969fa74acf46482c397b4cc Mon Sep 17 00:00:00 2001 From: xiaojingchen Date: Wed, 17 Jul 2019 20:53:16 +0800 Subject: [PATCH 4/4] fix bug --- tests/actions.go | 7 +++++++ tests/cluster_info.go | 4 ++-- tests/util.go | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/actions.go b/tests/actions.go index 58f29c93526..881a4039260 100644 --- a/tests/actions.go +++ b/tests/actions.go @@ -698,6 +698,13 @@ func (oa *operatorActions) CheckTidbClusterStatus(info *TidbClusterConfig) error return false, nil } + glog.V(4).Infof("check store labels") + if b, err := oa.storeLabelsIsSet(tc, info.TopologyKey); !b && err == nil { + return false, nil + } else if err != nil { + return false, err + } + glog.V(4).Infof("check tidb cluster begin passwordIsSet") if b, err := oa.passwordIsSet(info); !b && err == nil { return false, nil diff --git a/tests/cluster_info.go b/tests/cluster_info.go index db6abcf2a76..0caea9decd6 100644 --- a/tests/cluster_info.go +++ b/tests/cluster_info.go @@ -100,7 +100,7 @@ func (tc *TidbClusterConfig) BuildSubValues(path string) (string, error) { fmt.Sprintf(`level = "%s"`, pdLogLevel), "[replication]", fmt.Sprintf("max-replicas = %d", pdMaxReplicas), - `location-labels = ["region", "zone", "rack", "host"]`, + fmt.Sprintf(`location-labels = ["%s"]`, tc.TopologyKey), } tikvConfig := []string{ "[log]", @@ -113,7 +113,7 @@ func (tc *TidbClusterConfig) BuildSubValues(path string) (string, error) { "[log]", `level = "info"`, } - subValues := GetAffinityConfigOrDie(tc.ClusterName, tc.Namespace, tc.TopologyKey, pdConfig, tikvConfig, tidbConfig) + subValues := GetSubValuesOrDie(tc.ClusterName, tc.Namespace, tc.TopologyKey, pdConfig, tikvConfig, tidbConfig) subVaulesPath := fmt.Sprintf("%s/%s.yaml", path, tc.ClusterName) _, err := os.Stat(subVaulesPath) if err != nil { diff --git a/tests/util.go b/tests/util.go index 1cebce96af0..d47233b5c0f 100644 --- a/tests/util.go +++ b/tests/util.go @@ -115,7 +115,7 @@ type AffinityInfo struct { Config []string } -func GetAffinityConfigOrDie(clusterName, namespace, topologyKey string, pdConfig []string, tikvConfig []string, tidbConfig []string) string { +func GetSubValuesOrDie(clusterName, namespace, topologyKey string, pdConfig []string, tikvConfig []string, tidbConfig []string) string { temp, err := template.New("dt-affinity").Parse(affinityTemp) if err != nil { slack.NotifyAndPanic(err)