|
30 | 30 | from backend.flow.plugins.components.collections.common.download_backup_client import DownloadBackupClientComponent
|
31 | 31 | from backend.flow.plugins.components.collections.mysql.clear_machine import MySQLClearMachineComponent
|
32 | 32 | from backend.flow.plugins.components.collections.mysql.clone_user import CloneUserComponent
|
| 33 | +from backend.flow.plugins.components.collections.mysql.dns_manage import MySQLDnsManageComponent |
33 | 34 | from backend.flow.plugins.components.collections.mysql.exec_actuator_script import ExecuteDBActuatorScriptComponent
|
34 | 35 | from backend.flow.plugins.components.collections.mysql.sync_master import SyncMasterComponent
|
35 | 36 | from backend.flow.plugins.components.collections.mysql.trans_flies import TransFileComponent
|
|
41 | 42 | from backend.flow.utils.base.base_dataclass import Instance
|
42 | 43 | from backend.flow.utils.common_act_dataclass import DownloadBackupClientKwargs
|
43 | 44 | from backend.flow.utils.mysql.mysql_act_dataclass import (
|
| 45 | + CreateDnsKwargs, |
44 | 46 | DBMetaOPKwargs,
|
45 | 47 | DelServiceInstKwargs,
|
46 | 48 | DownloadMediaKwargs,
|
|
65 | 67 | def add_spider_slaves_sub_flow(
|
66 | 68 | uid: str,
|
67 | 69 | cluster: Cluster,
|
68 |
| - slave_domain: str, |
69 | 70 | add_spider_slaves: list,
|
70 | 71 | root_id: str,
|
71 | 72 | parent_global_data: dict,
|
72 | 73 | is_clone_user: bool = True,
|
| 74 | + slave_domain: str = None, |
73 | 75 | ):
|
74 | 76 | """
|
75 | 77 | 定义对原有的TenDB cluster集群添加spider slave节点的公共子流程
|
76 | 78 | 提供部分需要单据使用:比如添加从集群、扩容接入层等功能
|
77 | 79 | @param cluster: 待操作的集群
|
78 |
| - @param slave_domain: 带添加spider slave节点所要关联的域名 |
| 80 | + @param slave_domain: 带添加spider slave节点所要关联的域名, 这里参数只针对只读集群的部署 |
79 | 81 | @param add_spider_slaves: 待添加的slave机器列表信息
|
80 | 82 | @param root_id: flow流程的root_id
|
81 | 83 | @param parent_global_data: 本次子流程的对应上层流程的全局只读上下文
|
@@ -219,30 +221,35 @@ def add_spider_slaves_sub_flow(
|
219 | 221 | )
|
220 | 222 |
|
221 | 223 | # 阶段7 添加从域名
|
222 |
| - # sub_pipeline.add_act( |
223 |
| - # act_name=_("添加集群域名"), |
224 |
| - # act_component_code=MySQLDnsManageComponent.code, |
225 |
| - # kwargs=asdict( |
226 |
| - # CreateDnsKwargs( |
227 |
| - # bk_cloud_id=cluster.bk_cloud_id, |
228 |
| - # add_domain_name=slave_domain, |
229 |
| - # dns_op_exec_port=tmp_spider.port, |
230 |
| - # exec_ip=[ip_info["ip"] for ip_info in add_spider_slaves], |
231 |
| - # ) |
232 |
| - # ), |
233 |
| - # ) |
234 |
| - entrysub_process = BuildEntrysManageSubflow( |
235 |
| - root_id=root_id, |
236 |
| - ticket_data=parent_global_data, |
237 |
| - op_type=DnsOpType.CREATE, |
238 |
| - param={ |
239 |
| - "cluster_id": cluster.id, |
240 |
| - "port": tmp_spider.port, |
241 |
| - "add_ips": [ip_info["ip"] for ip_info in add_spider_slaves], |
242 |
| - "entry_role": [ClusterEntryRole.SLAVE_ENTRY.value], |
243 |
| - }, |
244 |
| - ) |
245 |
| - sub_pipeline.add_sub_pipeline(sub_flow=entrysub_process) |
| 224 | + if slave_domain: |
| 225 | + # 这里针对spider_slave集群部署的场景,从域名是传进来的 |
| 226 | + sub_pipeline.add_act( |
| 227 | + act_name=_("添加集群域名"), |
| 228 | + act_component_code=MySQLDnsManageComponent.code, |
| 229 | + kwargs=asdict( |
| 230 | + CreateDnsKwargs( |
| 231 | + bk_cloud_id=cluster.bk_cloud_id, |
| 232 | + add_domain_name=slave_domain, |
| 233 | + dns_op_exec_port=tmp_spider.port, |
| 234 | + exec_ip=[ip_info["ip"] for ip_info in add_spider_slaves], |
| 235 | + ) |
| 236 | + ), |
| 237 | + ) |
| 238 | + else: |
| 239 | + # 这里是针对扩容spider slave场景,所有的访问映射关系通过元数据获取 |
| 240 | + entry_sub_process = BuildEntrysManageSubflow( |
| 241 | + root_id=root_id, |
| 242 | + ticket_data=parent_global_data, |
| 243 | + op_type=DnsOpType.CREATE, |
| 244 | + param={ |
| 245 | + "cluster_id": cluster.id, |
| 246 | + "port": tmp_spider.port, |
| 247 | + "add_ips": [ip_info["ip"] for ip_info in add_spider_slaves], |
| 248 | + "entry_role": [ClusterEntryRole.SLAVE_ENTRY.value], |
| 249 | + }, |
| 250 | + ) |
| 251 | + sub_pipeline.add_sub_pipeline(sub_flow=entry_sub_process) |
| 252 | + |
246 | 253 | return sub_pipeline.build_sub_process(sub_name=_("集群[{}]添加spider slave节点".format(cluster.name)))
|
247 | 254 |
|
248 | 255 |
|
|
0 commit comments