Skip to content

Commit

Permalink
fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
River2000i committed Dec 25, 2024
1 parent 040e37b commit 8633039
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dm/config/security/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (s *Security) Clone() *Security {
return &clone
}

// WriteTLSContentToFiles will overwrite tls content to temp file and update path fields.
// WriteTLSContentToFiles write tls content to temp file and update tls path fields.
func (s *Security) WriteTLSContentToFiles(fileName string) error {
var err error
if s.SSLCA, err = certificate.WriteFile(fileName, s.SSLCABytes); err != nil {
Expand Down
8 changes: 5 additions & 3 deletions dm/loader/lightning.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,9 @@ func GetLightningConfig(globalCfg *lcfg.GlobalConfig, subtaskCfg *config.SubTask
return nil, err
}
cfg.TiDB.Security = &globalCfg.Security
// TODO: Just a workround since using SslContent cannot verify certificates correctly when lightning use pdctl lib access PD server.
// Write certificates content to file when loader using SslContent or set db security only.
// TODO: Using TLS content cannot verify certificates correctly when lightning access PD server.
// Workround is also need to set TLS path instead of only set TLS content.
// Write TLS content to file when loader using TLS content or set db security only.
if subtaskCfg.LoaderConfig.Security != nil {
// Only when ssl content is set and ssl file path is not set, the file will be written
if len(subtaskCfg.LoaderConfig.Security.SSLCABytes) != 0 && len(subtaskCfg.LoaderConfig.Security.SSLCertBytes) != 0 &&
Expand All @@ -348,7 +349,8 @@ func GetLightningConfig(globalCfg *lcfg.GlobalConfig, subtaskCfg *config.SubTask
cfg.Security.CertPath = subtaskCfg.LoaderConfig.Security.SSLCert
cfg.Security.KeyPath = subtaskCfg.LoaderConfig.Security.SSLKey
} else if subtaskCfg.To.Security != nil {
// Only when ssl content is set and ssl file path is not set, the file will be written
// Only when ssl content is set and ssl file path is not set, the file will be written.
// Using db security as lightning default security config.
if len(subtaskCfg.To.Security.SSLCABytes) != 0 && len(subtaskCfg.To.Security.SSLCertBytes) != 0 && len(subtaskCfg.To.Security.SSLKeyBytes) != 0 &&
subtaskCfg.To.Security.SSLCA == "" && subtaskCfg.To.Security.SSLCert == "" && subtaskCfg.To.Security.SSLKey == "" {
if err := subtaskCfg.To.Security.WriteTLSContentToFiles(subtaskCfg.Name); err != nil {
Expand Down

0 comments on commit 8633039

Please sign in to comment.