Skip to content

Commit

Permalink
fix: port parameter modification does not take effect
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangSetSail committed Jul 7, 2023
1 parent 604c850 commit c332d67
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions console/services/app_config/port_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def check_k8s_service_names(tenant_id, k8s_services):
if len(k8s_service_name) > 63:
raise AbortRequest("k8s_service_name must be no more than 63 characters")
if not re.fullmatch("[a-z]([-a-z0-9]*[a-z0-9])?", k8s_service_name):
raise AbortRequest("regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?'", msg_show="内部域名格式正确")
raise AbortRequest("regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?'", msg_show="内部域名格式不正确")

# make a map of k8s services
new_k8s_services = dict()
Expand All @@ -88,7 +88,7 @@ def check_k8s_service_name(tenant_id, k8s_service_name, component_id=""):
if len(k8s_service_name) > 63:
raise AbortRequest("k8s_service_name must be no more than 63 characters")
if not re.fullmatch("[a-z]([-a-z0-9]*[a-z0-9])?", k8s_service_name):
raise AbortRequest("regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?'", msg_show="内部域名格式正确")
raise AbortRequest("regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?'", msg_show="内部域名格式不正确")

# make k8s_service_name unique
port = port_repo.get_by_k8s_service_name(tenant_id, k8s_service_name)
Expand Down Expand Up @@ -716,7 +716,7 @@ def change_port_alias(self, tenant, service, deal_port, new_port_alias, k8s_serv
new_attr_name = new_port_alias + env.attr_name.replace(old_port_alias, '')
if env.container_port == deal_port.container_port:
env.attr_name = new_attr_name
if env.attr_name.endswith("HOST"):
if env.attr_name.endswith("HOST") and k8s_service_name:
if app.governance_mode != GovernanceModeEnum.BUILD_IN_SERVICE_MESH.name:
env.attr_value = k8s_service_name
else:
Expand All @@ -741,11 +741,11 @@ def change_port_alias(self, tenant, service, deal_port, new_port_alias, k8s_serv
region_api.add_service_env(service.service_region, tenant.tenant_name, service.service_alias, add_env)
env.save()

if k8s_service_name:
self.check_k8s_service_name(tenant.tenant_id, k8s_service_name, deal_port.service_id)
for port in ports:
if port.container_port == deal_port.container_port:
port.port_alias = new_port_alias
for port in ports:
if port.container_port == deal_port.container_port:
port.port_alias = new_port_alias
if k8s_service_name != "":
self.check_k8s_service_name(tenant.tenant_id, k8s_service_name, deal_port.service_id)
port.k8s_service_name = k8s_service_name
ports_dict = [port.to_dict() for port in ports]
if service.create_status == "complete":
Expand Down

0 comments on commit c332d67

Please sign in to comment.