From d3388e1bb7b41cddb427f5abe43e32bd890c0c54 Mon Sep 17 00:00:00 2001 From: JinLingChristopher Date: Thu, 10 Jun 2021 18:54:43 +0800 Subject: [PATCH] try to fix version issue above. --- pkg/cluster/template/scripts/cdc.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/cluster/template/scripts/cdc.go b/pkg/cluster/template/scripts/cdc.go index 1453495b7e..abf4f238b1 100644 --- a/pkg/cluster/template/scripts/cdc.go +++ b/pkg/cluster/template/scripts/cdc.go @@ -124,15 +124,25 @@ 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": {}, } - if _, ok := ignore[clusterVersion]; !ok && semver.Compare(clusterVersion, "v4.0.13") >= 0 { + // 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 + if semver.Major(clusterVersion) == "v4" && semver.Compare(clusterVersion, "v4.0.14") >= 0 { + c = c.WithDataDirEnabled() + } - if semver.Compare(clusterVersion, "v4.0.14") >= 0 || semver.Compare(clusterVersion, "v5.0.3") >= 0 { + if semver.Major(clusterVersion) == "v5" && semver.Compare(clusterVersion, "v5.0.3") >= 0 { + if _, ok := ignore[clusterVersion]; !ok { c = c.WithDataDirEnabled() } }