Skip to content

Commit

Permalink
fix: 修复tbinlogdumper流程一些问题 TencentBlueKing#7616
Browse files Browse the repository at this point in the history
  • Loading branch information
yksitu committed Oct 29, 2024
1 parent 1182a27 commit 63986c1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 38 deletions.
3 changes: 1 addition & 2 deletions dbm-ui/backend/db_meta/api/cluster/tendbha/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from backend.db_package.models import Package
from backend.flow.consts import MediumEnum
from backend.flow.engine.bamboo.scene.common.get_real_version import get_mysql_real_version, get_proxy_real_version
from backend.flow.utils.base.cc_topo_operate import CCTopoOperator
from backend.flow.utils.cc_manage import CcManage
from backend.flow.utils.mysql.mysql_module_operate import MysqlCCTopoOperator
from backend.flow.utils.tbinlogdumper.tbinlogdumper_module_operate import TBinlogDumperCCTopoOperator
Expand Down Expand Up @@ -243,7 +242,7 @@ def switch_tbinlogdumper_for_cluster(self, switch_ids: list):
inst.save()

# 创建新的服务实例
CCTopoOperator(cluster=self.cluster).create_tbinlogdumper_instances(inst)
TBinlogDumperCCTopoOperator(cluster=self.cluster).create_tbinlogdumper_instances(inst)

@classmethod
@transaction.atomic()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from backend.db_meta.models import Cluster, Machine
from backend.db_meta.models.extra_process import ExtraProcessInstance
from backend.flow.consts import DBA_SYSTEM_USER
from backend.flow.engine.bamboo.scene.common.atom_jobs.set_dns_sub_job import set_dns_atom_job
from backend.flow.engine.bamboo.scene.common.builder import SubBuilder
from backend.flow.engine.bamboo.scene.common.get_file_list import GetFileList
from backend.flow.engine.bamboo.scene.mysql.common.common_sub_flow import build_repl_by_manual_input_sub_flow
Expand All @@ -35,7 +34,6 @@
from backend.flow.plugins.components.collections.tbinlogdumper.trans_backup_file import TBinlogDumperTransFileComponent
from backend.flow.utils.mysql.mysql_act_dataclass import DownloadMediaKwargs, ExecActuatorKwargs, P2PFileKwargs
from backend.flow.utils.mysql.mysql_act_playload import MysqlActPayload
from backend.flow.utils.redis.redis_context_dataclass import ActKwargs
from backend.flow.utils.tbinlogdumper.context_dataclass import StopSlaveKwargs, TBinlogDumperFullSyncDataKwargs
from backend.flow.utils.tbinlogdumper.tbinlogdumper_act_payload import TBinlogDumperActPayload

Expand Down Expand Up @@ -83,14 +81,14 @@ def add_tbinlogdumper_sub_flow(
sub_pipeline = SubBuilder(root_id=root_id, data=parent_global_data)

# 初始化机器,为了安装tbinlogdumper
sub_pipeline.add_sub_pipeline(
sub_flow=init_machine_sub_flow(
root_id=root_id,
uid=uid,
init_machine=master.machine,
is_install_l5_agent=is_install_l5_agent,
if is_install_l5_agent:
sub_pipeline.add_sub_pipeline(
sub_flow=init_machine_sub_flow(
root_id=root_id,
uid=uid,
init_machine=master.machine,
)
)
)

# 阶段1 并行分发安装文件
sub_pipeline.add_act(
Expand Down Expand Up @@ -484,7 +482,6 @@ def init_machine_sub_flow(
uid: str,
root_id: str,
init_machine: Machine,
is_install_l5_agent: bool,
):
"""
定义安装tbinlogdumper之前初始化内容
Expand All @@ -494,37 +491,19 @@ def init_machine_sub_flow(
@param uid: 单据uid
@param root_id: 主流程的root_id
@param init_machine: 需要初始化的机器对象
@param is_install_l5_agent: 是否安装L5 agent
"""

# 声明子流程
parent_global_data = {"uid": uid}
sub_pipeline = SubBuilder(root_id=root_id, data=parent_global_data)

if is_install_l5_agent:
sub_pipeline.add_act(
act_name=_("安装L5agent"),
act_component_code=L5AgentInstallComponent.code,
kwargs={
"ip": init_machine.ip,
"bk_host_id": init_machine.bk_host_id,
},
)

else:
sub_pipeline.add_sub_pipeline(
set_dns_atom_job(
root_id=root_id,
ticket_data=parent_global_data,
act_kwargs=ActKwargs(),
param={
"force": False,
"ip": init_machine.ip,
"bk_biz_id": init_machine.bk_biz_id,
"bk_cloud_id": init_machine.bk_cloud_id,
"bk_city": init_machine.bk_city.logical_city.name,
},
)
)
sub_pipeline.add_act(
act_name=_("安装L5agent"),
act_component_code=L5AgentInstallComponent.code,
kwargs={
"ip": init_machine.ip,
"bk_host_id": init_machine.bk_host_id,
},
)
# 返回子流程
return sub_pipeline.build_sub_process(sub_name=_("初始化tbinlogdumper机器"))

0 comments on commit 63986c1

Please sign in to comment.