Skip to content

Commit

Permalink
Merge 204cbc3 into 0be11e9
Browse files Browse the repository at this point in the history
  • Loading branch information
nexustar authored Sep 16, 2022
2 parents 0be11e9 + 204cbc3 commit 551a468
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions embed/templates/scripts/run_cdc.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ exec bin/cdc server \
{{- if .TZ}}
--tz "{{.TZ}}" \
{{- end}}
{{- if .ClusterID}}
--cluster-id {{.ClusterID}} \
{{- end}}
{{- if .ConfigFileEnabled}}
--config conf/cdc.toml \
{{- end}}
Expand Down
7 changes: 6 additions & 1 deletion pkg/cluster/spec/cdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type CDCSpec struct {
Offline bool `yaml:"offline,omitempty"`
GCTTL int64 `yaml:"gc-ttl,omitempty" validate:"gc-ttl:editable"`
TZ string `yaml:"tz,omitempty" validate:"tz:editable"`
TiCDCClusterID string `yaml:"ticdc_cluster_id"`
NumaNode string `yaml:"numa_node,omitempty" validate:"numa_node:editable"`
Config map[string]interface{} `yaml:"config,omitempty" validate:"config:ignore"`
ResourceControl meta.ResourceControl `yaml:"resource_control,omitempty" validate:"resource_control:editable"`
Expand Down Expand Up @@ -171,14 +172,18 @@ func (i *CDCInstance) InitConfig(
}
}

if !tidbver.TiCDCSupportClusterID(clusterVersion) && spec.TiCDCClusterID != "" {
return errors.New("ticdc_cluster_id is only supported with TiCDC version v6.2.0 or later")
}

cfg := scripts.NewCDCScript(
i.GetHost(),
paths.Deploy,
paths.Log,
enableTLS,
spec.GCTTL,
spec.TZ,
).WithPort(spec.Port).WithNumaNode(spec.NumaNode).AppendEndpoints(topo.Endpoints(deployUser)...)
).WithPort(spec.Port).WithNumaNode(spec.NumaNode).AppendEndpoints(topo.Endpoints(deployUser)...).WithCDCClusterID(spec.TiCDCClusterID)

// doesn't work
if _, err := i.setTLSConfig(ctx, false, nil, paths); err != nil {
Expand Down
7 changes: 7 additions & 0 deletions pkg/cluster/template/scripts/cdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type CDCScript struct {
NumaNode string
GCTTL int64
TZ string
ClusterID string
TLSEnabled bool
Endpoints []*PDScript
ConfigFileEnabled bool
Expand Down Expand Up @@ -82,6 +83,12 @@ func (c *CDCScript) WithDataDirEnabled() *CDCScript {
return c
}

// WithCDCClusterID set CDC cluster-id
func (c *CDCScript) WithCDCClusterID(clusterID string) *CDCScript {
c.ClusterID = clusterID
return c
}

// Config generate the config file data.
func (c *CDCScript) Config() ([]byte, error) {
fp := path.Join("templates", "scripts", "run_cdc.sh.tpl")
Expand Down
5 changes: 5 additions & 0 deletions pkg/tidbver/tidbver.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ func TiCDCSupportDataDir(version string) bool {
return semver.Major(version) == "v4" && semver.Compare(version, "v4.0.14") >= 0
}

// TiCDCSupportClusterID return if the given version of TiCDC support --cluster-id param to identify TiCDC cluster
func TiCDCSupportClusterID(version string) bool {
return semver.Compare(version, "v6.2.0") >= 0 || strings.Contains(version, "nightly")
}

// TiCDCSupportRollingUpgrade return if the given version of TiCDC support rolling upgrade
// TiCDC support graceful rolling upgrade since v6.3.0
func TiCDCSupportRollingUpgrade(version string) bool {
Expand Down

0 comments on commit 551a468

Please sign in to comment.