Skip to content

Commit

Permalink
fix(backend): 处理spider master 和 spider slave 端口不同的情况 TencentBlueKing#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ymakedaq authored and iSecloud committed Oct 18, 2024
1 parent 472eb45 commit 28a6fb1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,16 @@ 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:
raise Exception(_("至少需要2个以上的spider节点"))
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节点"))
Expand All @@ -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]))
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand Down

0 comments on commit 28a6fb1

Please sign in to comment.