Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cluster: enable data-dir for versions above v5.0.3 #1838

Merged
merged 1 commit into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pkg/cluster/spec/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,9 @@ cdc_servers:
"v5.0.0-rc": {false, false, false},
"v5.1.0-alpha": {true, true, false},
"v5.2.0-alpha": {true, true, false},
"v6.0.0-alpha": {true, true, true},
"v6.1.0": {true, true, true},
"v99.0.0": {true, true, true},
}

checkByVersion := func(version string) {
Expand All @@ -751,9 +754,9 @@ cdc_servers:

wanted := expected[version]

c.Assert(cfg.ConfigFileEnabled, Equals, wanted.configSupported)
c.Assert(cfg.DataDirEnabled, Equals, wanted.dataDirSupported)
c.Assert(len(cfg.DataDir) != 0, Equals, wanted.dataDir)
c.Assert(cfg.ConfigFileEnabled, Equals, wanted.configSupported, Commentf(version))
c.Assert(cfg.DataDirEnabled, Equals, wanted.dataDirSupported, Commentf(version))
c.Assert(len(cfg.DataDir) != 0, Equals, wanted.dataDir, Commentf(version))
}

for k := range expected {
Expand Down
18 changes: 8 additions & 10 deletions pkg/cluster/template/scripts/cdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,26 +124,24 @@ func (c *CDCScript) AppendEndpoints(ends ...*PDScript) *CDCScript {

// PatchByVersion update fields by cluster version
func (c *CDCScript) PatchByVersion(clusterVersion, dataDir string) *CDCScript {
// for those version, cdc does not support --data-dir
ignore := map[string]struct{}{
"v5.0.0-rc": {},
"v5.1.0-alpha": {},
"v5.2.0-alpha": {},
}

// config support since v4.0.13, ignore v5.0.0-rc
// the same to data-dir, but we treat it as --sort-dir
if semver.Compare(clusterVersion, "v4.0.13") >= 0 && clusterVersion != "v5.0.0-rc" {
c = c.WithConfigFileEnabled().WithDataDir(dataDir)
}

// cdc support --data-dir since v4.0.14 and v5.0.3, but not the ignore above
// cdc support --data-dir since v4.0.14 and v5.0.3
if semver.Major(clusterVersion) == "v4" && semver.Compare(clusterVersion, "v4.0.14") >= 0 {
c = c.WithDataDirEnabled()
}

if semver.Major(clusterVersion) == "v5" && semver.Compare(clusterVersion, "v5.0.3") >= 0 {
if _, ok := ignore[clusterVersion]; !ok {
// for those version above v5.0.3, cdc does not support --data-dir
ignoreVersion := map[string]struct{}{
"v5.1.0-alpha": {},
"v5.2.0-alpha": {},
}
if semver.Compare(clusterVersion, "v5.0.3") >= 0 {
if _, ok := ignoreVersion[clusterVersion]; !ok {
c = c.WithDataDirEnabled()
}
}
Expand Down