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

upstream(ticdc): init client go global cfg (#9525) #9552

Merged
Merged
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
17 changes: 17 additions & 0 deletions pkg/upstream/upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/pingcap/tiflow/pkg/pdutil"
"github.com/pingcap/tiflow/pkg/txnutil/gc"
"github.com/pingcap/tiflow/pkg/version"
tikvconfig "github.com/tikv/client-go/v2/config"
"github.com/tikv/client-go/v2/tikv"
pd "github.com/tikv/pd/client"
uatomic "github.com/uber-go/atomic"
Expand Down Expand Up @@ -119,6 +120,8 @@ func initUpstream(ctx context.Context, up *Upstream, gcServiceID string) error {
up.err.Store(err)
return errors.Trace(err)
}
// init the tikv client tls global config
initGlobalConfig(up.SecurityConfig)

up.PDClient, err = pd.NewClientWithContext(
ctx, up.PdEndpoints, up.SecurityConfig.PDSecurityOption(),
Expand Down Expand Up @@ -212,6 +215,20 @@ func initUpstream(ctx context.Context, up *Upstream, gcServiceID string) error {
return nil
}

// initGlobalConfig initializes the global config for tikv client tls.
// region cache health check will use the global config.
// TODO: remove this function after tikv client tls is refactored.
func initGlobalConfig(secCfg *config.SecurityConfig) {
if secCfg.CAPath != "" || secCfg.CertPath != "" || secCfg.KeyPath != "" {
conf := tikvconfig.GetGlobalConfig()
conf.Security.ClusterSSLCA = secCfg.CAPath
conf.Security.ClusterSSLCert = secCfg.CertPath
conf.Security.ClusterSSLKey = secCfg.KeyPath
conf.Security.ClusterVerifyCN = secCfg.CertAllowedCN
tikvconfig.StoreGlobalConfig(conf)
}
}

// Close all resources.
func (up *Upstream) Close() {
up.mu.Lock()
Expand Down