diff --git a/dbm-ui/backend/flow/engine/bamboo/scene/spider/spider_cluster_rollback_flow.py b/dbm-ui/backend/flow/engine/bamboo/scene/spider/spider_cluster_rollback_flow.py index 89dbcbfdba..a014237e1b 100644 --- a/dbm-ui/backend/flow/engine/bamboo/scene/spider/spider_cluster_rollback_flow.py +++ b/dbm-ui/backend/flow/engine/bamboo/scene/spider/spider_cluster_rollback_flow.py @@ -16,6 +16,7 @@ from django.utils.translation import ugettext as _ from backend.configuration.constants import DBType +from backend.constants import IP_PORT_DIVIDER from backend.db_meta.enums import InstanceStatus from backend.db_meta.models import Cluster from backend.db_services.mysql.fixpoint_rollback.handlers import FixPointRollbackHandler @@ -122,6 +123,10 @@ def tendb_rollback_data(self): raise TendbGetBackupInfoFailedException(message=_("获取spider节点备份信息不存在")) if backup_info["spider_node"] == "": raise TendbGetBackupInfoFailedException(message=_("获取spider节点备份信息为空")) + if "tdbctl_node" not in backup_info: + raise TendbGetBackupInfoFailedException(message=_("获取中控节点备份信息不存在")) + if backup_info["tdbctl_node"] == "": + raise TendbGetBackupInfoFailedException(message=_("获取中控节点备份信息为空")) if not check_storage_database(target_cluster.bk_cloud_id, spider_node["ip"], spider_node["port"]): logger.error("cluster {} check database fail".format(target_cluster.id)) raise NormalSpiderFlowException( @@ -165,7 +170,17 @@ def tendb_rollback_data(self): root_id=self.root_id, ticket_data=copy.deepcopy(self.data), cluster=spd_cluster ) ) - + ctl_cluster = copy.deepcopy(spd_cluster) + ctl_cluster["backupinfo"] = backup_info["tdbctl_node"] + ctl_cluster["rollback_port"] = spider_node["admin_port"] + ctl_cluster["file_target_path"] = f'{self.backup_target_path}/{spider_node["admin_port"]}' + ctl_cluster["instance"] = f'{self.backup_target_path}{IP_PORT_DIVIDER}{spider_node["admin_port"]}' + ctl_cluster["init_command"] = "set tc_admin=0" + spd_sub_pipeline.add_sub_pipeline( + sub_flow=spider_recover_sub_flow( + root_id=self.root_id, ticket_data=copy.deepcopy(self.data), cluster=ctl_cluster + ) + ) cluster = {"proxy_status": InstanceStatus.RUNNING.value, "proxy_ids": [target_spider.id]} spd_sub_pipeline.add_act( act_name=_("写入初始化实例的db_meta元信息"), diff --git a/dbm-ui/backend/flow/utils/mysql/mysql_act_playload.py b/dbm-ui/backend/flow/utils/mysql/mysql_act_playload.py index cbf7a39b5e..f2e106fc14 100644 --- a/dbm-ui/backend/flow/utils/mysql/mysql_act_playload.py +++ b/dbm-ui/backend/flow/utils/mysql/mysql_act_playload.py @@ -1026,12 +1026,7 @@ def get_rollback_data_restore_payload(self, **kwargs): """ MYSQL 定点回档恢复备份介质 """ - # if ( - # self.ticket_data["ticket_type"] == TicketType.TENDBCLUSTER_ROLLBACK_CLUSTER - # or self.ticket_data["ticket_type"] == TicketType.MYSQL_ROLLBACK_CLUSTER - # ): - # self.cluster["master_ip"] = "" - # self.cluster["master_port"] = 0 + init_command = self.cluster.get("init_command", "") index_file = os.path.basename(self.cluster["backupinfo"]["index"]["file_name"]) payload = { "db_type": DBActuatorTypeEnum.MySQL.value, @@ -1059,6 +1054,7 @@ def get_rollback_data_restore_payload(self, **kwargs): "ignore_databases": self.cluster["databases_ignore"], "ignore_tables": self.cluster["tables_ignore"], "recover_binlog": self.cluster["recover_binlog"], + "init_command": init_command, }, "src_instance": {"host": "", "port": 0}, "change_master": self.cluster["change_master"],