Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: set up & deregister ghost ssl (#13057)
p0nyd3daf60dab61
diff --git a/backend/component/ghost/config.go b/backend/component/ghost/config.goindex ff4d12ae04..936d62a391 100644--- a/backend/component/ghost/config.go+++ b/backend/component/ghost/config.go@@ -229,6 +229,9 @@ func NewMigrationContext(ctx context.Context, taskID int, taskCreatedTs int64, dmigrationContext.TLSCertificate = certmigrationContext.TLSKey = keymigrationContext.TLSAllowInsecure = true+ if err := migrationContext.SetupTLS(); err != nil {+ return nil, errors.Wrapf(err, "failed to set up tls")+ }}migrationContext.InspectorConnectionConfig.Key.Port = portmigrationContext.CliUser = dataSource.Usernamediff --git a/backend/runner/plancheck/ghost_sync_executor.go b/backend/runner/plancheck/ghost_sync_executor.goindex dc65a0891a..a57894513c 100644--- a/backend/runner/plancheck/ghost_sync_executor.go+++ b/backend/runner/plancheck/ghost_sync_executor.go@@ -7,6 +7,7 @@ import ("time""github.com/github/gh-ost/go/logic"+ gomysql "github.com/go-sql-driver/mysql""github.com/pkg/errors""github.com/bytebase/bytebase/backend/common"@@ -108,6 +109,12 @@ func (e *GhostSyncExecutor) Run(ctx context.Context, config *storepb.PlanCheckRuif err != nil {return nil, common.Wrapf(err, common.Internal, "failed to create migration context")}+ defer func() {+ // Use migrationContext.Uuid as the tls_config_key by convention.+ // We need to deregister it when gh-ost exits.+ // https://github.com/bytebase/gh-ost2/pull/4+ gomysql.DeregisterTLSConfig(migrationContext.Uuid)+ }()migrator := logic.NewMigrator(migrationContext, "bb")diff --git a/backend/runner/taskrun/schema_update_ghost_sync_executor.go b/backend/runner/taskrun/schema_update_ghost_sync_executor.goindex 25d27e4227..baf2f314a7 100644--- a/backend/runner/taskrun/schema_update_ghost_sync_executor.go+++ b/backend/runner/taskrun/schema_update_ghost_sync_executor.go@@ -11,6 +11,8 @@ import ("github.com/github/gh-ost/go/logic""github.com/pkg/errors"+ gomysql "github.com/go-sql-driver/mysql"+"github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/ghost"@@ -105,6 +107,12 @@ func (exec *SchemaUpdateGhostSyncExecutor) runGhostMigration(ctx context.Contextif err != nil {return true, nil, errors.Wrap(err, "failed to init migrationContext for gh-ost")}+ defer func() {+ // Use migrationContext.Uuid as the tls_config_key by convention.+ // We need to deregister it when gh-ost exits.+ // https://github.com/bytebase/gh-ost2/pull/4+ gomysql.DeregisterTLSConfig(migrationContext.Uuid)+ }()migrator := logic.NewMigrator(migrationContext, "bb")diff --git a/go.mod b/go.modindex 8764de285f..1ba5d966b0 100644--- a/go.mod+++ b/go.mod@@ -317,7 +317,7 @@ require (// fix potential security issue(CVE-2020-26160) introduced by indirect dependency.replace github.com/dgrijalva/jwt-go => github.com/form3tech-oss/jwt-go v3.2.6-0.20210809144907-32ab6a8243d7+incompatible-replace github.com/github/gh-ost => github.com/bytebase/gh-ost2 v0.0.0-20240226091811-8bc079577744+replace github.com/github/gh-ost => github.com/bytebase/gh-ost2 v0.0.0-20240731091141-e7a12a9401abreplace github.com/pingcap/tidb => github.com/bytebase/tidb2 v0.0.0-20231129002249-5bbb6bb83940diff --git a/go.sum b/go.sumindex a4f2924c46..e6c9c57ffc 100644--- a/go.sum+++ b/go.sum@@ -778,8 +778,8 @@ github.com/bytebase/antlr/v4 v4.0.0-20240628084508-8a85f73b60b3 h1:TSzeWiRWr7T8hgithub.com/bytebase/antlr/v4 v4.0.0-20240628084508-8a85f73b60b3/go.mod h1:ykhjIPiv0IWpu3OGXCHdz2eUSe8UNGGD6baqjs8jSuU=github.com/bytebase/bq-parser v0.0.0-20240529032606-614a0230b8f7 h1:tDEAGOa3tSmTOfUshYBwsOqunGajGu7SBL8NMlM71bU=github.com/bytebase/bq-parser v0.0.0-20240529032606-614a0230b8f7/go.mod h1:uDDETOUNvOuKjha/g+oC8NdqhcGyGEl4NOeoKh2OhNE=-github.com/bytebase/gh-ost2 v0.0.0-20240226091811-8bc079577744 h1:quO7ADa+58XcEOXBqAB0Ofd0RJbzal94TmXd60ezrx4=-github.com/bytebase/gh-ost2 v0.0.0-20240226091811-8bc079577744/go.mod h1:VRPqaDM7UYxJbcCtQkjBcNkxW17p6LJJdkM/nYwQhqg=+github.com/bytebase/gh-ost2 v0.0.0-20240731091141-e7a12a9401ab h1:hJ3tfjfm5D63QwCH+znK1ZQQzk9/rG4Jjz7CSxVtSrQ=+github.com/bytebase/gh-ost2 v0.0.0-20240731091141-e7a12a9401ab/go.mod h1:VRPqaDM7UYxJbcCtQkjBcNkxW17p6LJJdkM/nYwQhqg=github.com/bytebase/go-lsp v0.0.0-20240130071507-c04b5c75010c h1:W832GNANCst4C6TgYbQnKKxbuMZKQxTD4++b3HOuzBo=github.com/bytebase/go-lsp v0.0.0-20240130071507-c04b5c75010c/go.mod h1:SULmZY7YNBsvNiQbrb/BEDdEJ84TGnfyUQxaHt8t8rY=github.com/bytebase/go-mssqldb v0.0.0-20240613094500-7f9ca9381f8f h1:hcjpjIaVVPuZOrHvkXiu7HDSow03aDdK+fXTZM6g93c=