Skip to content

Commit

Permalink
upstream(ticdc): init client go global cfg (#9525)
Browse files Browse the repository at this point in the history
close #9523
  • Loading branch information
sdojjy authored Aug 11, 2023
1 parent 447e512 commit dd8da8e
Showing 1 changed file with 17 additions and 0 deletions.
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

0 comments on commit dd8da8e

Please sign in to comment.