diff --git a/dbm-ui/backend/flow/engine/bamboo/scene/spider/append_deploy_ctl_flow.py b/dbm-ui/backend/flow/engine/bamboo/scene/spider/append_deploy_ctl_flow.py index 13c4c74ae3..5f85793eee 100644 --- a/dbm-ui/backend/flow/engine/bamboo/scene/spider/append_deploy_ctl_flow.py +++ b/dbm-ui/backend/flow/engine/bamboo/scene/spider/append_deploy_ctl_flow.py @@ -212,6 +212,9 @@ def run(self): master_spiders = cluster_obj.proxyinstance_set.filter( tendbclusterspiderext__spider_role=TenDBClusterSpiderRole.SPIDER_MASTER.value ) + slave_spiders = cluster_obj.proxyinstance_set.filter( + tendbclusterspiderext__spider_role=TenDBClusterSpiderRole.SPIDER_SLAVE.value + ) master_spider_ips = [c.machine.ip for c in master_spiders] logging.info("master_spider_ips: %s" % [c.machine.ip for c in master_spiders]) if len(master_spider_ips) < 2: @@ -219,7 +222,6 @@ def run(self): leader_spider = master_spiders[0] primary_ctl_ip = master_spider_ips[0] slave_ctp_ips = master_spider_ips[1:] - spiders = cluster_obj.proxyinstance_set.all() backends = cluster_obj.storageinstance_set.all() if len(backends) < 0: raise Exception(_("沒有发现remote节点")) @@ -231,8 +233,14 @@ def run(self): # 赋值给全局参数 sub_flow_context = copy.deepcopy(self.data) sub_flow_context["spider_ip_list"] = [ - {"ip": value} for value in list(set([c.machine.ip for c in spiders])) + {"ip": value} for value in list(set([c.machine.ip for c in master_spiders])) ] + # 处理slave spider + if len(slave_spiders) > 0: + sub_flow_context["slave_spider_ip_list"] = [ + {"ip": value} for value in list(set([c.machine.ip for c in slave_spiders])) + ] + sub_flow_context["slave_spider_port"] = slave_spiders[0].port sub_flow_context["tdbctl_ip_list"] = [ {"ip": value} for value in list(set([c.machine.ip for c in master_spiders])) ] diff --git a/dbm-ui/backend/flow/plugins/components/collections/spider/add_system_user_in_cluster.py b/dbm-ui/backend/flow/plugins/components/collections/spider/add_system_user_in_cluster.py index 41c86e8acf..5d9c8704f1 100644 --- a/dbm-ui/backend/flow/plugins/components/collections/spider/add_system_user_in_cluster.py +++ b/dbm-ui/backend/flow/plugins/components/collections/spider/add_system_user_in_cluster.py @@ -54,7 +54,12 @@ def _execute(self, data, parent_data) -> bool: params["role"] = PrivRole.SPIDER.value if not self.__add_priv(params=params): return False - + # 新集群部署,对所有的新的slave spider节点授权, 迁移的集群可能端口不一致 + for spider_ip in global_data["slave_spider_ip_list"]: + params["address"] = f'{spider_ip["ip"]}{IP_PORT_DIVIDER}{global_data["slave_spider_port"]}' + params["role"] = PrivRole.SPIDER.value + if not self.__add_priv(params=params): + return False # 新集群部署,对所有的新的ctl节点授权 if is_append_deploy: for ctl_ip in global_data["tdbctl_ip_list"]: