Skip to content

Commit

Permalink
Fix bug for only one directory in TiFlash storage.* configuration (#938)
Browse files Browse the repository at this point in the history
Signed-off-by: JaySon-Huang <tshent@qq.com>
  • Loading branch information
JaySon-Huang authored and AstroProfundis committed Nov 27, 2020
1 parent b1243ed commit 621bbfe
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
18 changes: 18 additions & 0 deletions pkg/cluster/spec/parse_topology_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,24 @@ tiflash_servers:
c.Assert(topo.TiFlashServers[0].LogDir, check.Equals, "")
})

// test if there is only one path in storage.main.dir
withTempFile(`
tiflash_servers:
- host: 172.16.5.140
data_dir: /hhd0/tiflash
config:
storage.main.dir: [/ssd0/tiflash]
`, func(file string) {
topo := Specification{}
err := ParseTopologyYaml(file, &topo)
c.Assert(err, check.IsNil)
ExpandRelativeDir(&topo)

c.Assert(topo.TiFlashServers[0].DeployDir, check.Equals, "/home/tidb/deploy/tiflash-9000")
c.Assert(topo.TiFlashServers[0].DataDir, check.Equals, "/ssd0/tiflash")
c.Assert(topo.TiFlashServers[0].LogDir, check.Equals, "")
})

// test tiflash storage section defined data dir
// should always define storage.main.dir if any 'storage.*' is defined
withTempFile(`
Expand Down
6 changes: 5 additions & 1 deletion pkg/cluster/spec/tiflash.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ func (s TiFlashSpec) GetOverrideDataDir() (string, error) {
i++
}
sort.Strings(keys)
return firstPath + "," + strings.Join(keys, ","), nil
joinedPaths := firstPath
if len(keys) > 0 {
joinedPaths += "," + strings.Join(keys, ",")
}
return joinedPaths, nil
}

// TiFlashComponent represents TiFlash component.
Expand Down

0 comments on commit 621bbfe

Please sign in to comment.