Skip to content

Commit cb1a2f8

Browse files
committed
chore(controller): change drycc gateway listener name
1 parent f18a21e commit cb1a2f8

3 files changed

Lines changed: 13 additions & 16 deletions

File tree

charts/controller/templates/controller-route.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ spec:
1414
- group: gateway.networking.k8s.io
1515
kind: Gateway
1616
name: drycc-gateway
17-
sectionName: drycc-gateway-listener-http
17+
sectionName: http
1818
{{- if .Values.global.certManagerEnabled }}
1919
- group: gateway.networking.k8s.io
2020
kind: Gateway
2121
name: drycc-gateway
22-
sectionName: drycc-gateway-listener-https
22+
sectionName: https
2323
{{- end }}
2424
rules:
2525
- matches:

rootfs/api/models/gateway.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,14 @@ def _get_tls_domain(self, auto_tls):
3434
domains = domains.exclude(certificate=None)
3535
return domains
3636

37-
def _get_listener_name(self, port, protocol, suffix=None):
38-
names = [self.app.id, str(port)]
37+
def _get_listener_name(self, port, protocol, index):
3938
if protocol in ("TCP", "TLS", "HTTP"):
40-
names.append("TCP")
39+
protocol = "TCP"
4140
elif protocol in ("HTTPS", ):
42-
names.append("MIX")
41+
protocol = "MIX"
4342
else:
44-
names.append("UDP")
45-
if suffix:
46-
names.append(suffix)
47-
return "-".join(names).lower()
43+
protocol = "UDP"
44+
return "-".join([protocol, str(port), str(index)]).lower()
4845

4946
def add(self, port, protocol):
5047
# check port
@@ -76,7 +73,7 @@ def listeners(self):
7673
auto_tls else domain.certificate.name)
7774
listeners.append({
7875
"allowedRoutes": {"namespaces": {"from": "All"}},
79-
"name": self._get_listener_name(port, protocol, domain.domain),
76+
"name": self._get_listener_name(port, protocol, domains.index(domain)),
8077
"port": port,
8178
"hostname": domain.domain,
8279
"protocol": protocol,
@@ -85,7 +82,7 @@ def listeners(self):
8582
else:
8683
listeners.append({
8784
"allowedRoutes": {"namespaces": {"from": "All"}},
88-
"name": self._get_listener_name(port, protocol),
85+
"name": self._get_listener_name(port, protocol, 0),
8986
"port": port,
9087
"protocol": protocol,
9188
})

rootfs/api/tests/test_gateway.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ def test_add_listener(self):
9292
"name": "bing-gateway",
9393
"listeners": [
9494
{
95-
"name": "%s-8000-tcp" % app_id,
95+
"name": "tcp-8000-%s" % 0,
9696
"port": 8000,
9797
"protocol": "HTTP",
9898
"allowedRoutes": {"namespaces": {"from": "All"}}
9999
},
100100
{
101-
"name": "%s-443-tcp" % app_id,
101+
"name": "tcp-443-%s" % 0,
102102
"port": 443,
103103
"protocol": "HTTP",
104104
"allowedRoutes": {"namespaces": {"from": "All"}}
@@ -116,9 +116,9 @@ def add_tls_listener(self, name, protocol):
116116
self.assertEqual(response.status_code, 201)
117117
response = self.client.get('/v2/apps/{}/gateways/'.format(app_id))
118118
if protocol == "HTTPS":
119-
listener_name = "%s-443-mix-%s" % (app_id, domain)
119+
listener_name = "mix-443-%s" % 0
120120
else:
121-
listener_name = "%s-443-tcp-%s" % (app_id, domain)
121+
listener_name = "tcp-443-%s" % 0
122122
results = [{
123123
"app": app_id,
124124
"owner": "autotest",

0 commit comments

Comments
 (0)