Skip to content

Commit

Permalink
cherry pick pingcap#4430 to release-1.3
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <[email protected]>
  • Loading branch information
KanShiori authored and ti-srebot committed Feb 22, 2022
1 parent 2cba41f commit ebeae91
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
6 changes: 4 additions & 2 deletions pkg/manager/member/tiflash_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand Down
24 changes: 16 additions & 8 deletions pkg/manager/member/tiflash_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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]
Expand All @@ -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"
Expand All @@ -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]
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit ebeae91

Please sign in to comment.