From 2db9a5fa84345b742d27201e0bb7926fd927cdd5 Mon Sep 17 00:00:00 2001 From: yksitu <1297650644@qq.com> Date: Wed, 18 Sep 2024 15:06:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=97=B6=E5=87=BA=E7=8E=B0=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20#6968?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sqlserver/restore_dbs_full_backup.go | 26 +++++++++++-------- .../scene/sqlserver/sqlserver_add_slave.py | 13 ++++++++++ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/dbm-services/sqlserver/db-tools/dbactuator/pkg/components/sqlserver/restore_dbs_full_backup.go b/dbm-services/sqlserver/db-tools/dbactuator/pkg/components/sqlserver/restore_dbs_full_backup.go index 31c52af860..6a9bb3eb6e 100644 --- a/dbm-services/sqlserver/db-tools/dbactuator/pkg/components/sqlserver/restore_dbs_full_backup.go +++ b/dbm-services/sqlserver/db-tools/dbactuator/pkg/components/sqlserver/restore_dbs_full_backup.go @@ -144,7 +144,7 @@ func (r *RestoreDBSForFullComp) PreCheck() error { } // GetRestorePath 获取这次恢复路径 -// 全量备份恢复的路径的优先级:app_setting表[RESTORE_PATH] > app_setting表[DATA_PATH] > 默认 +// 全量备份恢复的路径的优先级:app_setting表[RESTORE_PATH] > 默认 func (r *RestoreDBSForFullComp) GetRestorePath() error { var infos []AppSettingInfo checkSQL := fmt.Sprintf( @@ -154,17 +154,21 @@ func (r *RestoreDBSForFullComp) GetRestorePath() error { if err := r.LocalDB.Queryx(&infos, checkSQL); err != nil { return fmt.Errorf("select APP_SETTING failed: %v", err) } - if infos[0].RestorePath.Valid && infos[0].RestorePath.String != "" { - r.RestoreDataPath = infos[0].RestorePath.String - r.RestoreLogPath = infos[0].RestorePath.String - return nil - } - if infos[0].DataPath.Valid && infos[0].LogPath.Valid && - infos[0].DataPath.String != "" && infos[0].LogPath.String != "" { - r.RestoreDataPath = infos[0].DataPath.String - r.RestoreLogPath = infos[0].LogPath.String - return nil + // 如果aap_setting没有记录,则走默认 + if len(infos) > 0 { + if infos[0].RestorePath.Valid && infos[0].RestorePath.String != "" { + r.RestoreDataPath = infos[0].RestorePath.String + r.RestoreLogPath = infos[0].RestorePath.String + return nil + } + if infos[0].DataPath.Valid && infos[0].LogPath.Valid && + infos[0].DataPath.String != "" && infos[0].LogPath.String != "" { + r.RestoreDataPath = infos[0].DataPath.String + r.RestoreLogPath = infos[0].LogPath.String + return nil + } } + // 获取默认值 if defaultPath, err := r.LocalDB.GetDefaultPath(); err != nil { return fmt.Errorf("get default path failed: %v", err) } else { diff --git a/dbm-ui/backend/flow/engine/bamboo/scene/sqlserver/sqlserver_add_slave.py b/dbm-ui/backend/flow/engine/bamboo/scene/sqlserver/sqlserver_add_slave.py index 8feb801ee1..6d88436dca 100644 --- a/dbm-ui/backend/flow/engine/bamboo/scene/sqlserver/sqlserver_add_slave.py +++ b/dbm-ui/backend/flow/engine/bamboo/scene/sqlserver/sqlserver_add_slave.py @@ -20,6 +20,7 @@ from backend.flow.engine.bamboo.scene.sqlserver.base_flow import BaseFlow from backend.flow.engine.bamboo.scene.sqlserver.common_sub_flow import ( build_always_on_sub_flow, + clone_configs_sub_flow, install_sqlserver_sub_flow, install_surrounding_apps_sub_flow, sync_dbs_for_cluster_sub_flow, @@ -186,6 +187,18 @@ def run_flow(self): ) ) + # 先做克隆周边配置 + cluster_sub_pipeline.add_sub_pipeline( + sub_flow=clone_configs_sub_flow( + uid=self.data["uid"], + root_id=self.root_id, + source_host=Host(ip=master_instance.machine.ip, bk_cloud_id=cluster.bk_cloud_id), + source_port=master_instance.port, + target_host=Host(**info["new_slave_host"]), + target_port=master_instance.port, + ) + ) + # 删除随机账号 cluster_sub_pipeline.add_act( act_name=_("drop job user"),