From ebeae91aba6407d4e081417bdfe39e105c91edfd Mon Sep 17 00:00:00 2001 From: Shiori Date: Tue, 22 Feb 2022 21:19:43 +0800 Subject: [PATCH] cherry pick #4430 to release-1.3 Signed-off-by: ti-srebot --- pkg/manager/member/tiflash_util.go | 6 ++++-- pkg/manager/member/tiflash_util_test.go | 24 ++++++++++++++++-------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/pkg/manager/member/tiflash_util.go b/pkg/manager/member/tiflash_util.go index 632dd21ea7..a6559c1004 100644 --- a/pkg/manager/member/tiflash_util.go +++ b/pkg/manager/member/tiflash_util.go @@ -137,7 +137,7 @@ func getTiFlashConfigV2(tc *v1alpha1.TidbCluster) *v1alpha1.TiFlashConfigWraper { // storage // check "path" to be compatible with old version - if common.Get("path") == nil && common.Get("storage") == nil { + if common.Get("path") == nil && common.Get("storage.main.dir") == nil { paths := []string{} for i := range tc.Spec.TiFlash.StorageClaims { paths = append(paths, fmt.Sprintf("/data%d/db", i)) @@ -149,8 +149,10 @@ func getTiFlashConfigV2(tc *v1alpha1.TidbCluster) *v1alpha1.TiFlashConfigWraper } // check "raft.kvstore_path" to be compatible with old version if common.Get("raft.kvstore_path") == nil { - common.SetIfNil("storage.raft.dir", "/data0/kvstore") + common.SetIfNil("storage.raft.dir", []string{"/data0/kvstore"}) } + // workaround for issue #4091 about v5.4.0 TiFlash + common.SetIfNil("tmp_path", "/data0/tmp") // port common.SetIfNil("tcp_port", int64(9000)) diff --git a/pkg/manager/member/tiflash_util_test.go b/pkg/manager/member/tiflash_util_test.go index d6153853dc..1f4543d79e 100644 --- a/pkg/manager/member/tiflash_util_test.go +++ b/pkg/manager/member/tiflash_util_test.go @@ -1512,6 +1512,7 @@ func TestTestGetTiFlashConfig(t *testing.T) { expectCommonCfg: ` http_port = 8123 tcp_port = 9000 + tmp_path = "/data0/tmp" [flash] service_addr = "0.0.0.0:3930" tidb_status_addr = "test-tidb.default.svc:10080" @@ -1531,7 +1532,7 @@ func TestTestGetTiFlashConfig(t *testing.T) { [storage.main] dir = ["/data0/db"] [storage.raft] - dir = "/data0/kvstore"`, + dir = ["/data0/kvstore"]`, expectProxyCfg: ` log-level = "info" @@ -1549,6 +1550,7 @@ func TestTestGetTiFlashConfig(t *testing.T) { expectCommonCfg: ` https_port = 8123 tcp_port_secure = 9000 + tmp_path = "/data0/tmp" [flash] service_addr = "0.0.0.0:3930" tidb_status_addr = "test-tidb.default.svc:10080" @@ -1572,7 +1574,7 @@ func TestTestGetTiFlashConfig(t *testing.T) { [storage.main] dir = ["/data0/db"] [storage.raft] - dir = "/data0/kvstore"`, + dir = ["/data0/kvstore"]`, expectProxyCfg: ` log-level = "info" [security] @@ -1597,6 +1599,7 @@ func TestTestGetTiFlashConfig(t *testing.T) { expectCommonCfg: ` https_port = 8123 tcp_port_secure = 9000 + tmp_path = "/data0/tmp" [flash] service_addr = "0.0.0.0:3930" tidb_status_addr = "test-tidb.default.svc:10080" @@ -1621,7 +1624,7 @@ func TestTestGetTiFlashConfig(t *testing.T) { [storage.main] dir = ["/data0/db"] [storage.raft] - dir = "/data0/kvstore"`, + dir = ["/data0/kvstore"]`, expectProxyCfg: ` log-level = "info" [security] @@ -1651,6 +1654,7 @@ func TestTestGetTiFlashConfig(t *testing.T) { expectCommonCfg: ` http_port = 8123 tcp_port = 9000 + tmp_path = "/data0/tmp" [flash] service_addr = "0.0.0.0:3930" tidb_status_addr = "test-tidb.default.svc:10080" @@ -1670,7 +1674,7 @@ func TestTestGetTiFlashConfig(t *testing.T) { [storage.main] dir = ["/data0/db","/data1/db"] [storage.raft] - dir = "/data0/kvstore"`, + dir = ["/data0/kvstore"]`, expectProxyCfg: ` log-level = "info" @@ -1690,6 +1694,7 @@ func TestTestGetTiFlashConfig(t *testing.T) { expectCommonCfg: ` http_port = 8123 tcp_port = 9000 + tmp_path = "/data0/tmp" [flash] service_addr = "0.0.0.0:3930" tidb_status_addr = "cluster-1-tidb.default.svc:10080" @@ -1709,7 +1714,7 @@ func TestTestGetTiFlashConfig(t *testing.T) { [storage.main] dir = ["/data0/db"] [storage.raft] - dir = "/data0/kvstore"`, + dir = ["/data0/kvstore"]`, expectProxyCfg: ` log-level = "info" @@ -1727,6 +1732,7 @@ func TestTestGetTiFlashConfig(t *testing.T) { expectCommonCfg: ` http_port = 8123 tcp_port = 9000 + tmp_path = "/data0/tmp" [flash] service_addr = "0.0.0.0:3930" tidb_status_addr = "test-tidb.default.svc:10080" @@ -1746,7 +1752,7 @@ func TestTestGetTiFlashConfig(t *testing.T) { [storage.main] dir = ["/data0/db"] [storage.raft] - dir = "/data0/kvstore"`, + dir = ["/data0/kvstore"]`, expectProxyCfg: ` log-level = "info" @@ -1767,6 +1773,7 @@ func TestTestGetTiFlashConfig(t *testing.T) { expectCommonCfg: ` http_port = 8123 tcp_port = 9000 + tmp_path = "/data0/tmp" [flash] service_addr = "0.0.0.0:3930" tidb_status_addr = "test-tidb.default.svc:10080" @@ -1786,7 +1793,7 @@ func TestTestGetTiFlashConfig(t *testing.T) { [storage.main] dir = ["/data0/db"] [storage.raft] - dir = "/data0/kvstore"`, + dir = ["/data0/kvstore"]`, expectProxyCfg: ` log-level = "info" @@ -1807,6 +1814,7 @@ func TestTestGetTiFlashConfig(t *testing.T) { expectCommonCfg: ` http_port = 8123 tcp_port = 9000 + tmp_path = "/data0/tmp" [flash] service_addr = "0.0.0.0:3930" tidb_status_addr = "cluster-1-tidb-peer.default.svc:10080" @@ -1826,7 +1834,7 @@ func TestTestGetTiFlashConfig(t *testing.T) { [storage.main] dir = ["/data0/db"] [storage.raft] - dir = "/data0/kvstore"`, + dir = ["/data0/kvstore"]`, expectProxyCfg: ` log-level = "info"