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: support TiCDC cluster id #2042

Merged
merged 2 commits into from
Sep 22, 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
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