Skip to content

Commit

Permalink
fix: get component port is_outer_service is error (#1519)
Browse files Browse the repository at this point in the history
Signed-off-by: 张启航 <[email protected]>
  • Loading branch information
ZhangSetSail authored Nov 14, 2024
1 parent d86be66 commit 1bb1c36
Showing 1 changed file with 32 additions and 25 deletions.
57 changes: 32 additions & 25 deletions console/views/app_config/app_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,33 +65,40 @@ def get(self, request, *args, **kwargs):
outer_url = "{0}:{1}".format(variables["outer_service"]["domain"], variables["outer_service"]["port"])
port_info["outer_url"] = outer_url
port_info["bind_domains"] = []
path = ("/api-gateway/v1/" + self.tenant_name + "/routes/http/domains?service_alias=" +
self.service.service_alias + "&port=" + str(port.container_port))
body = region_api.api_gateway_get_proxy(self.region, self.tenant_name, path, None)
if body.get("list", []):
port_info["bind_domains"] = [{
"protocol": "http",
"domain_type": "www",
"ID": -1,
"domain_name": host,
"container_port": port.container_port
} for host in body.get("list", [])]
if port_info['protocol'] == 'http':
if port.protocol == "http":
path = ("/api-gateway/v1/" + self.tenant_name + "/routes/http/domains?service_alias=" +
self.service.service_alias + "&port=" + str(port.container_port))
body = region_api.api_gateway_get_proxy(self.region, self.tenant_name, path, None)
if body.get("list", []):
port_info["bind_domains"] = [{
"protocol": "http",
"domain_type": "www",
"ID": -1,
"domain_name": host,
"container_port": port.container_port
} for host in body.get("list", [])]
port_info["is_outer_service"] = len(port_info["bind_domains"]) > 0
port_info["is_outer_service"] = True
port.is_outer_service = True
port_info["is_outer_service"] = True
port.is_outer_service = True
else:
port.is_outer_service = False
port_info["is_outer_service"] = False
else:
port.is_outer_service = False
port_info["is_outer_service"] = False
bind_tcp_domains = domain_service.get_tcp_port_bind_domains(self.service, port.container_port)
if bind_tcp_domains:
port_info["bind_tcp_domains"] = [domain.to_dict() for domain in bind_tcp_domains]
port_info["is_outer_service"] = True
port.is_outer_service = True
else:
port_info["bind_tcp_domains"] = []
port_info["is_outer_service"] = False
port.is_outer_service = False
bind_tcp_domains = domain_service.get_tcp_port_bind_domains(self.service, port.container_port)
if bind_tcp_domains:
outer = False
tcp_domain_list = []
for tcp_domain in bind_tcp_domains:
if tcp_domain.is_outer_service:
outer = True
tcp_domain_list.append(tcp_domain.to_dict())
port_info["bind_tcp_domains"] = tcp_domain_list
port_info["is_outer_service"] = outer
port.is_outer_service = outer
else:
port_info["bind_tcp_domains"] = []
port_info["is_outer_service"] = False
port.is_outer_service = False
port.save()
port_list.append(port_info)
result = general_message(200, "success", "查询成功", list=port_list)
Expand Down

0 comments on commit 1bb1c36

Please sign in to comment.