Skip to content

Commit

Permalink
sprintfix: 2.0 Proxy Data endpoint 渲染有误 (fixed #1340)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuoZhuoCrayon committed Feb 10, 2023
1 parent 17d2eff commit b6a7483
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
9 changes: 2 additions & 7 deletions apps/backend/agent/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,8 @@ def fetch_gse_servers_info(
callback_url = host_ap.callback_url or settings.BKAPP_NODEMAN_CALLBACK_URL
elif host.node_type == constants.NodeType.PROXY:
task_server_hosts = host_ap.cluster_endpoint_info.outer_hosts
if agent_setup_info.is_legacy:
data_server_hosts = host_ap.data_endpoint_info.outer_hosts
bt_file_server_hosts = host_ap.file_endpoint_info.outer_hosts
else:
# 对于新版本的 Agent,file data 的 endpoint 链接 proxy(可以是同台或同云区域内其他 proxy 的 file data)
data_server_hosts = [host.inner_ip or host.inner_ipv6]
bt_file_server_hosts = [host.inner_ip or host.inner_ipv6]
bt_file_server_hosts = host_ap.file_endpoint_info.outer_hosts
data_server_hosts = host_ap.data_endpoint_info.outer_hosts
package_url = host_ap.package_outer_url
# 不同接入点使用不同的callback_url默认情况下接入点callback_url为空,先取接入点,为空的情况下使用原来的配置
callback_url = host_ap.outer_callback_url or settings.BKAPP_NODEMAN_OUTER_CALLBACK_URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ def __post_init__(self):
proxy_tls_cli_cert_file: str = json.dumps(proxy_tls_cli_cert_file)[1:-1]
proxy_tls_cli_key_file: str = json.dumps(proxy_tls_cli_key_file)[1:-1]

if self.host.node_type == constants.NodeType.PROXY:
# Agent 配置中 file data 的 endpoint 链接 proxy(可以是同台(自身)或同云区域内其他 proxy 的 file data)
file_hosts_for_agent: typing.List[str] = [self.host.inner_ip or self.host.inner_ipv6]
data_hosts_for_agent: typing.List[str] = [self.host.inner_ip or self.host.inner_ipv6]
else:
# 其他情况取实际上游
file_hosts_for_agent: typing.List[str] = gse_servers_info["bt_file_server_hosts"]
data_hosts_for_agent: typing.List[str] = gse_servers_info["data_server_hosts"]

contexts: typing.List[context_dataclass.GseConfigContext] = [
context_dataclass.AgentConfigContext(
run_mode=(constants.GseAgentRunMode.AGENT.value, constants.GseAgentRunMode.PROXY.value)[
Expand All @@ -91,16 +100,10 @@ def __post_init__(self):
]
),
data_endpoints=",".join(
[
f"{data_host}:{self.ap.port_config['data_port']}"
for data_host in gse_servers_info["data_server_hosts"]
]
[f"{data_host}:{self.ap.port_config['data_port']}" for data_host in data_hosts_for_agent]
),
file_endpoints=",".join(
[
f"{file_host}:{self.ap.port_config['file_svr_port']}"
for file_host in gse_servers_info["bt_file_server_hosts"]
]
[f"{file_host}:{self.ap.port_config['file_svr_port']}" for file_host in file_hosts_for_agent]
),
),
context_dataclass.AgentBaseConfigContext(
Expand Down Expand Up @@ -144,7 +147,7 @@ def __post_init__(self):
tls_key_file=proxy_tls_key_file,
),
context_dataclass.FileProxyConfigContext(
upstream_ip=random.choice(self.ap.file_endpoint_info.outer_hosts or [""]),
upstream_ip=random.choice(gse_servers_info["bt_file_server_hosts"] or [""]),
upstream_port=self.ap.port_config.get(
"file_topology_bind_port", constants.GSE_PORT_DEFAULT_VALUE["file_topology_bind_port"]
),
Expand Down

0 comments on commit b6a7483

Please sign in to comment.