Skip to content

Commit

Permalink
This is an automated cherry-pick of tikv#7563
Browse files Browse the repository at this point in the history
close tikv#7561

Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
Connor1996 authored and ti-chi-bot committed Feb 28, 2024
1 parent 6eeb69d commit 636a6af
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 10 deletions.
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ require (
github.com/pingcap/kvproto v0.0.0-20230407040905-68d0eebd564a
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3
github.com/pingcap/sysutil v1.0.1-0.20230407040306-fb007c5aff21
<<<<<<< HEAD
github.com/pingcap/tidb-dashboard v0.0.0-20230921035205-31ea86f64e20
=======
github.com/pingcap/tidb-dashboard v0.0.0-20231218095437-aa621ed4de2c
>>>>>>> 83da4c26b (dashboard: Pass TLS info to dashboard to fix TiKV heap profiling (#7563))
github.com/prometheus/client_golang v1.11.1
github.com/prometheus/common v0.26.0
github.com/sasha-s/go-deadlock v0.2.0
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,13 @@ github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 h1:HR/ylkkLmGdSSDaD8
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
github.com/pingcap/sysutil v1.0.1-0.20230407040306-fb007c5aff21 h1:QV6jqlfOkh8hqvEAgwBZa+4bSgO0EeKC7s5c6Luam2I=
github.com/pingcap/sysutil v1.0.1-0.20230407040306-fb007c5aff21/go.mod h1:QYnjfA95ZaMefyl1NO8oPtKeb8pYUdnDVhQgf+qdpjM=
<<<<<<< HEAD
github.com/pingcap/tidb-dashboard v0.0.0-20230921035205-31ea86f64e20 h1:QRFMPcmEfhNod57i1yy6RMFZDXK17SmuOwfZs/wTfC8=
github.com/pingcap/tidb-dashboard v0.0.0-20230921035205-31ea86f64e20/go.mod h1:EZ90+V5S4TttbYag6oKZ3jcNKRwZe1Mc9vXwOt9JBYw=
=======
github.com/pingcap/tidb-dashboard v0.0.0-20231218095437-aa621ed4de2c h1:iEZwsxxOxXaH0zEfzVAn6fjveOlPh3v3DsYlhWJAVi0=
github.com/pingcap/tidb-dashboard v0.0.0-20231218095437-aa621ed4de2c/go.mod h1:ucZBRz52icb23T/5Z4CsuUHmarYiin7p2MeiVBe+o8c=
>>>>>>> 83da4c26b (dashboard: Pass TLS info to dashboard to fix TiKV heap profiling (#7563))
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e h1:FBaTXU8C3xgt/drM58VHxojHo/QoG1oPsgWTGvaSpO4=
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e/go.mod h1:A7mrd7WHBl1o63LE2bIBGEJMTNWXqhgmYiOvMLxozfs=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
Expand Down
3 changes: 3 additions & 0 deletions pkg/dashboard/adapter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ func GenDashboardConfig(srv *server.Server) (*config.Config, error) {
if dashboardCfg.ClusterTLSConfig, err = cfg.Security.ToTLSConfig(); err != nil {
return nil, err
}
if dashboardCfg.ClusterTLSInfo, err = cfg.Security.ToTLSInfo(); err != nil {
return nil, err
}
if dashboardCfg.TiDBTLSConfig, err = cfg.Dashboard.ToTiDBTLSConfig(); err != nil {
return nil, err
}
Expand Down
31 changes: 21 additions & 10 deletions pkg/utils/grpcutil/grpcutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ type TLSConfig struct {
SSLKEYBytes []byte
}

// ToTLSInfo converts TLSConfig to transport.TLSInfo.
func (s TLSConfig) ToTLSInfo() (*transport.TLSInfo, error) {
if len(s.CertPath) == 0 && len(s.KeyPath) == 0 {
return nil, nil
}
allowedCN, err := s.GetOneAllowedCN()
if err != nil {
return nil, err
}

return &transport.TLSInfo{
CertFile: s.CertPath,
KeyFile: s.KeyPath,
TrustedCAFile: s.CAPath,
AllowedCN: allowedCN,
}, nil
}

// ToTLSConfig generates tls config.
func (s TLSConfig) ToTLSConfig() (*tls.Config, error) {
if len(s.SSLCABytes) != 0 || len(s.SSLCertBytes) != 0 || len(s.SSLKEYBytes) != 0 {
Expand All @@ -68,19 +86,12 @@ func (s TLSConfig) ToTLSConfig() (*tls.Config, error) {
}, nil
}

if len(s.CertPath) == 0 && len(s.KeyPath) == 0 {
tlsInfo, err := s.ToTLSInfo()
if tlsInfo == nil {
return nil, nil
}
allowedCN, err := s.GetOneAllowedCN()
if err != nil {
return nil, err
}

tlsInfo := transport.TLSInfo{
CertFile: s.CertPath,
KeyFile: s.KeyPath,
TrustedCAFile: s.CAPath,
AllowedCN: allowedCN,
return nil, errs.ErrEtcdTLSConfig.Wrap(err).GenWithStackByCause()
}

tlsConfig, err := tlsInfo.ClientConfig()
Expand Down
4 changes: 4 additions & 0 deletions tests/integrations/client/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ require (
github.com/pingcap/errcode v0.3.0 // indirect
github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c // indirect
github.com/pingcap/sysutil v1.0.1-0.20230407040306-fb007c5aff21 // indirect
<<<<<<< HEAD
github.com/pingcap/tidb-dashboard v0.0.0-20230921035205-31ea86f64e20 // indirect
=======
github.com/pingcap/tidb-dashboard v0.0.0-20231218095437-aa621ed4de2c // indirect
>>>>>>> 83da4c26b (dashboard: Pass TLS info to dashboard to fix TiKV heap profiling (#7563))
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand Down
5 changes: 5 additions & 0 deletions tests/integrations/client/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,13 @@ github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 h1:HR/ylkkLmGdSSDaD8
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
github.com/pingcap/sysutil v1.0.1-0.20230407040306-fb007c5aff21 h1:QV6jqlfOkh8hqvEAgwBZa+4bSgO0EeKC7s5c6Luam2I=
github.com/pingcap/sysutil v1.0.1-0.20230407040306-fb007c5aff21/go.mod h1:QYnjfA95ZaMefyl1NO8oPtKeb8pYUdnDVhQgf+qdpjM=
<<<<<<< HEAD
github.com/pingcap/tidb-dashboard v0.0.0-20230921035205-31ea86f64e20 h1:QRFMPcmEfhNod57i1yy6RMFZDXK17SmuOwfZs/wTfC8=
github.com/pingcap/tidb-dashboard v0.0.0-20230921035205-31ea86f64e20/go.mod h1:EZ90+V5S4TttbYag6oKZ3jcNKRwZe1Mc9vXwOt9JBYw=
=======
github.com/pingcap/tidb-dashboard v0.0.0-20231218095437-aa621ed4de2c h1:iEZwsxxOxXaH0zEfzVAn6fjveOlPh3v3DsYlhWJAVi0=
github.com/pingcap/tidb-dashboard v0.0.0-20231218095437-aa621ed4de2c/go.mod h1:ucZBRz52icb23T/5Z4CsuUHmarYiin7p2MeiVBe+o8c=
>>>>>>> 83da4c26b (dashboard: Pass TLS info to dashboard to fix TiKV heap profiling (#7563))
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e h1:FBaTXU8C3xgt/drM58VHxojHo/QoG1oPsgWTGvaSpO4=
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e/go.mod h1:A7mrd7WHBl1o63LE2bIBGEJMTNWXqhgmYiOvMLxozfs=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
Expand Down
4 changes: 4 additions & 0 deletions tests/integrations/mcs/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ require (
github.com/pingcap/errcode v0.3.0 // indirect
github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c // indirect
github.com/pingcap/sysutil v1.0.1-0.20230407040306-fb007c5aff21 // indirect
<<<<<<< HEAD
github.com/pingcap/tidb-dashboard v0.0.0-20230921035205-31ea86f64e20 // indirect
=======
github.com/pingcap/tidb-dashboard v0.0.0-20231218095437-aa621ed4de2c // indirect
>>>>>>> 83da4c26b (dashboard: Pass TLS info to dashboard to fix TiKV heap profiling (#7563))
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect
Expand Down
5 changes: 5 additions & 0 deletions tests/integrations/mcs/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,13 @@ github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 h1:HR/ylkkLmGdSSDaD8
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
github.com/pingcap/sysutil v1.0.1-0.20230407040306-fb007c5aff21 h1:QV6jqlfOkh8hqvEAgwBZa+4bSgO0EeKC7s5c6Luam2I=
github.com/pingcap/sysutil v1.0.1-0.20230407040306-fb007c5aff21/go.mod h1:QYnjfA95ZaMefyl1NO8oPtKeb8pYUdnDVhQgf+qdpjM=
<<<<<<< HEAD
github.com/pingcap/tidb-dashboard v0.0.0-20230921035205-31ea86f64e20 h1:QRFMPcmEfhNod57i1yy6RMFZDXK17SmuOwfZs/wTfC8=
github.com/pingcap/tidb-dashboard v0.0.0-20230921035205-31ea86f64e20/go.mod h1:EZ90+V5S4TttbYag6oKZ3jcNKRwZe1Mc9vXwOt9JBYw=
=======
github.com/pingcap/tidb-dashboard v0.0.0-20231218095437-aa621ed4de2c h1:iEZwsxxOxXaH0zEfzVAn6fjveOlPh3v3DsYlhWJAVi0=
github.com/pingcap/tidb-dashboard v0.0.0-20231218095437-aa621ed4de2c/go.mod h1:ucZBRz52icb23T/5Z4CsuUHmarYiin7p2MeiVBe+o8c=
>>>>>>> 83da4c26b (dashboard: Pass TLS info to dashboard to fix TiKV heap profiling (#7563))
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e h1:FBaTXU8C3xgt/drM58VHxojHo/QoG1oPsgWTGvaSpO4=
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e/go.mod h1:A7mrd7WHBl1o63LE2bIBGEJMTNWXqhgmYiOvMLxozfs=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
Expand Down
4 changes: 4 additions & 0 deletions tests/integrations/tso/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ require (
github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c // indirect
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 // indirect
github.com/pingcap/sysutil v1.0.1-0.20230407040306-fb007c5aff21 // indirect
<<<<<<< HEAD
github.com/pingcap/tidb-dashboard v0.0.0-20230921035205-31ea86f64e20 // indirect
=======
github.com/pingcap/tidb-dashboard v0.0.0-20231218095437-aa621ed4de2c // indirect
>>>>>>> 83da4c26b (dashboard: Pass TLS info to dashboard to fix TiKV heap profiling (#7563))
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand Down
5 changes: 5 additions & 0 deletions tests/integrations/tso/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,13 @@ github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3 h1:HR/ylkkLmGdSSDaD8
github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
github.com/pingcap/sysutil v1.0.1-0.20230407040306-fb007c5aff21 h1:QV6jqlfOkh8hqvEAgwBZa+4bSgO0EeKC7s5c6Luam2I=
github.com/pingcap/sysutil v1.0.1-0.20230407040306-fb007c5aff21/go.mod h1:QYnjfA95ZaMefyl1NO8oPtKeb8pYUdnDVhQgf+qdpjM=
<<<<<<< HEAD
github.com/pingcap/tidb-dashboard v0.0.0-20230921035205-31ea86f64e20 h1:QRFMPcmEfhNod57i1yy6RMFZDXK17SmuOwfZs/wTfC8=
github.com/pingcap/tidb-dashboard v0.0.0-20230921035205-31ea86f64e20/go.mod h1:EZ90+V5S4TttbYag6oKZ3jcNKRwZe1Mc9vXwOt9JBYw=
=======
github.com/pingcap/tidb-dashboard v0.0.0-20231218095437-aa621ed4de2c h1:iEZwsxxOxXaH0zEfzVAn6fjveOlPh3v3DsYlhWJAVi0=
github.com/pingcap/tidb-dashboard v0.0.0-20231218095437-aa621ed4de2c/go.mod h1:ucZBRz52icb23T/5Z4CsuUHmarYiin7p2MeiVBe+o8c=
>>>>>>> 83da4c26b (dashboard: Pass TLS info to dashboard to fix TiKV heap profiling (#7563))
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e h1:FBaTXU8C3xgt/drM58VHxojHo/QoG1oPsgWTGvaSpO4=
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e/go.mod h1:A7mrd7WHBl1o63LE2bIBGEJMTNWXqhgmYiOvMLxozfs=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
Expand Down

0 comments on commit 636a6af

Please sign in to comment.