Skip to content

Commit

Permalink
Merge branch 'master' into issue-1839
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Apr 12, 2022
2 parents b2debdf + bdc10b9 commit 480710b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
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

0 comments on commit 480710b

Please sign in to comment.