Skip to content

Commit

Permalink
feat: tendbCluster定点回档增加中控节点的回档 TencentBlueKing#7352
Browse files Browse the repository at this point in the history
  • Loading branch information
zfrendo committed Oct 15, 2024
1 parent c6f1cb0 commit b4c8372
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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元信息"),
Expand Down
8 changes: 2 additions & 6 deletions dbm-ui/backend/flow/utils/mysql/mysql_act_playload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"],
Expand Down

0 comments on commit b4c8372

Please sign in to comment.