Skip to content

Commit

Permalink
fix: port tcp route not show
Browse files Browse the repository at this point in the history
Signed-off-by: 张启航 <[email protected]>
  • Loading branch information
ZhangSetSail committed Dec 19, 2024
1 parent 930dab4 commit aa59142
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions console/services/app_check_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ def __save_port(self, tenant, service, ports):
port_service.delete_service_port(tenant, service)
region_info = region_services.get_enterprise_region_by_region_name(tenant.enterprise_id, service.service_region)
for port in ports:
if port["protocol"] not in ["tcp", "udp", "http"]:
port["protocol"] = "tcp"
code, msg, port_data = port_service.add_service_port(
tenant, service, int(port["container_port"]), port["protocol"],
service.service_alias.upper() + str(port["container_port"]), True, True)
Expand Down
2 changes: 1 addition & 1 deletion console/views/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def post(self, request, *args, **kwargs):
@never_cache
def get(self, request, *args, **kwargs):
path = request.get_full_path().replace("/console", "")
resp = region_api.get_proxy(request.GET.get("region_name"), path)
resp = region_api.get_proxy(request.GET.get("region_name"), path, app_id=request.GET.get("appID"))
result = general_message(200, "success", "请求成功", bean=resp['bean'], list=resp['list'])
return Response(result, status=result["code"])

Expand Down
8 changes: 6 additions & 2 deletions www/apiclient/regionapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2786,10 +2786,13 @@ def post_proxy(self, region_name, path, data):
res, body = self._post(url, self.default_headers, region=region_name, body=json.dumps(data))
return body

def get_proxy(self, region_name, path, check_status=True):
def get_proxy(self, region_name, path, check_status=True, app_id=""):
region_info = self.get_region_info(region_name)
if not region_info:
raise ServiceHandleException("region not found")
if app_id:
region_app_id = region_app_repo.get_region_app_id(region_name, app_id)
path = path.replace("appID=" + str(app_id), "appID=" + region_app_id) + "&intID=" + str(app_id)
url = region_info.url + path
self._set_headers(region_info.token)
res, body = self._get(url, self.default_headers, region=region_name, check_status=check_status)
Expand Down Expand Up @@ -2993,9 +2996,10 @@ def api_gateway_bind_tcp_domain(self, region, tenant_name, k8s_service_name, con
"servicePort": container_port
}
}
region_app_id = region_app_repo.get_region_app_id(region, app_id)

path = "/v2/proxy-pass/gateway/" + tenant_name + "/routes/tcp?appID=" + str(
app_id) + "&service_id=" + service_id + "&service_type=" + service_type + "&port=" + str(container_port)
region_app_id) + "&service_id=" + service_id + "&service_type=" + service_type + "&port=" + str(container_port)
return self.post_proxy(region, path, data)

def api_gateway_bind_http_domain(self, service_name, region, tenant_name, domains, svc, app_id):
Expand Down

0 comments on commit aa59142

Please sign in to comment.