Skip to content

Commit

Permalink
Merge pull request #2182 from datawire/flynn/dev/listener-fixes
Browse files Browse the repository at this point in the history
Fix some broken listener logic [apro #809]
  • Loading branch information
khussey authored Jan 13, 2020
2 parents 072f487 + bd6bceb commit 06e770e
Show file tree
Hide file tree
Showing 63 changed files with 3,058 additions and 3,856 deletions.
214 changes: 149 additions & 65 deletions python/ambassador/envoy/v2/v2listener.py

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions python/ambassador/ir/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class IR:
saved_secrets: Dict[str, SavedSecret]
secret_handler: SecretHandler
secret_root: str
sidecar_cluster_name: Optional[str]
tls_contexts: Dict[str, IRTLSContext]
tls_module: Optional[IRAmbassadorTLS]
tracing: Optional[IRTracing]
Expand Down Expand Up @@ -143,6 +144,7 @@ def __init__(self, aconf: Config, secret_handler=None, file_checker=None, logger
self.saved_secrets = {}
self.secret_info = {}
self.services = {}
self.sidecar_cluster_name = None
self.tls_contexts = {}
self.tls_module = None
self.tracing = None
Expand Down Expand Up @@ -602,6 +604,10 @@ def add_cluster(self, cluster: IRCluster) -> IRCluster:
if not self.has_cluster(cluster.name):
self.clusters[cluster.name] = cluster

if cluster.is_edge_stack_sidecar():
self.logger.info(f"IR: cluster {cluster.name} is the sidecar")
self.sidecar_cluster_name = cluster.name

return self.clusters[cluster.name]

def merge_cluster(self, cluster: IRCluster) -> bool:
Expand Down
7 changes: 7 additions & 0 deletions python/ambassador/ir/ircluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ def __init__(self, ir: 'IR', aconf: Config, parent_ir_resource: 'IRResource',
self._hostname = hostname
self._namespace = namespace
self._port = port
self._is_sidecar = False

if self._hostname == '127.0.0.1' and self._port == 8500:
self._is_sidecar = True

super().__init__(
ir=ir, aconf=aconf, rkey=rkey, location=location,
Expand Down Expand Up @@ -331,6 +335,9 @@ def setup(self, ir: 'IR', aconf: Config) -> bool:

return True

def is_edge_stack_sidecar(self) -> bool:
return self.is_active() and self._is_sidecar

def endpoints_required(self, load_balancer) -> bool:
required = False

Expand Down
6 changes: 5 additions & 1 deletion python/ambassador/ir/irtlscontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ def __init__(self, ir: 'IR', aconf: Config,
def pretty(self) -> str:
secret_name = self.secret_info.get('secret', '-no secret-')
hoststr = getattr(self, "hosts", "-any-")
fbstr = " (fallback)" if self.is_fallback else ""

return f"<IRTLSContext {self.name} ns {self.namespace} fallback {self.is_fallback}: hosts {hoststr} secret {secret_name}>"
rcf = self.get('redirect_cleartext_from', None)
rcfstr = f" rcf {rcf}" if (rcf is not None) else ""

return f"<IRTLSContext {self.name}.{self.namespace}{rcfstr}{fbstr}: hosts {hoststr} secret {secret_name}>"

def setup(self, ir: 'IR', aconf: Config) -> bool:
if not self.get('_ambassador_enabled', False):
Expand Down
92 changes: 46 additions & 46 deletions python/tests/gold/acceptancegrpcbridgetest/snapshots/snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,30 @@
"kind": "Service",
"metadata": {
"annotations": {
"getambassador.io/config": "---\napiVersion: ambassador/v0\nkind: Module\nname: ambassador\nconfig:\n enable_grpc_http11_bridge: True\nambassador_id: acceptancegrpcbridgetest\n\n---\napiVersion: ambassador/v0\nkind: Mapping\ngrpc: True\nprefix: /echo.EchoService/\nrewrite: /echo.EchoService/\nname: acceptancegrpcbridgetest-egrpc\nservice: acceptancegrpcbridgetest-egrpc\nambassador_id: acceptancegrpcbridgetest\n",
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{\"getambassador.io/config\":\"---\\napiVersion: ambassador/v0\\nkind: Module\\nname: ambassador\\nconfig:\\n enable_grpc_http11_bridge: True\\nambassador_id: acceptancegrpcbridgetest\\n\\n---\\napiVersion: ambassador/v0\\nkind: Mapping\\ngrpc: True\\nprefix: /echo.EchoService/\\nrewrite: /echo.EchoService/\\nname: acceptancegrpcbridgetest-egrpc\\nservice: acceptancegrpcbridgetest-egrpc\\nambassador_id: acceptancegrpcbridgetest\\n\"},\"labels\":{\"app.kubernetes.io/component\":\"ambassador-service\",\"kat-ambassador-id\":\"acceptancegrpcbridgetest\",\"scope\":\"AmbassadorTest\"},\"name\":\"acceptancegrpcbridgetest\",\"namespace\":\"default\"},\"spec\":{\"ports\":[{\"name\":\"http\",\"port\":80,\"protocol\":\"TCP\",\"targetPort\":8080},{\"name\":\"https\",\"port\":443,\"protocol\":\"TCP\",\"targetPort\":8443}],\"selector\":{\"service\":\"acceptancegrpcbridgetest\"},\"type\":\"NodePort\"}}\n"
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{},\"labels\":{\"kat-ambassador-id\":\"acceptancegrpcbridgetest\",\"scope\":\"AmbassadorTest\",\"service\":\"acceptancegrpcbridgetest-admin\"},\"name\":\"acceptancegrpcbridgetest-admin\",\"namespace\":\"default\"},\"spec\":{\"ports\":[{\"name\":\"acceptancegrpcbridgetest-admin\",\"port\":8877,\"targetPort\":8877}],\"selector\":{\"service\":\"acceptancegrpcbridgetest\"},\"type\":\"NodePort\"}}\n"
},
"creationTimestamp": "2020-01-10T16:54:05Z",
"creationTimestamp": "2020-01-13T06:08:46Z",
"labels": {
"app.kubernetes.io/component": "ambassador-service",
"kat-ambassador-id": "acceptancegrpcbridgetest",
"scope": "AmbassadorTest"
"scope": "AmbassadorTest",
"service": "acceptancegrpcbridgetest-admin"
},
"name": "acceptancegrpcbridgetest",
"name": "acceptancegrpcbridgetest-admin",
"namespace": "default",
"resourceVersion": "59402",
"selfLink": "/api/v1/namespaces/default/services/acceptancegrpcbridgetest",
"uid": "cff10a30-33c9-11ea-966c-16b58b03f3a1"
"resourceVersion": "34097",
"selfLink": "/api/v1/namespaces/default/services/acceptancegrpcbridgetest-admin",
"uid": "28635cb0-35cb-11ea-83a4-122f10fc3771"
},
"spec": {
"clusterIP": "10.106.98.38",
"clusterIP": "10.104.99.166",
"externalTrafficPolicy": "Cluster",
"ports": [
{
"name": "http",
"nodePort": 32763,
"port": 80,
"protocol": "TCP",
"targetPort": 8080
},
{
"name": "https",
"nodePort": 30485,
"port": 443,
"name": "acceptancegrpcbridgetest-admin",
"nodePort": 31779,
"port": 8877,
"protocol": "TCP",
"targetPort": 8443
"targetPort": 8877
}
],
"selector": {
Expand All @@ -69,37 +61,40 @@
"kind": "Service",
"metadata": {
"annotations": {
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{},\"labels\":{\"kat-ambassador-id\":\"acceptancegrpcbridgetest\",\"scope\":\"AmbassadorTest\",\"service\":\"acceptancegrpcbridgetest-admin\"},\"name\":\"acceptancegrpcbridgetest-admin\",\"namespace\":\"default\"},\"spec\":{\"ports\":[{\"name\":\"acceptancegrpcbridgetest-admin\",\"port\":8877,\"targetPort\":8877}],\"selector\":{\"service\":\"acceptancegrpcbridgetest\"},\"type\":\"NodePort\"}}\n"
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{},\"labels\":{\"kat-ambassador-id\":\"acceptancegrpcbridgetest\",\"scope\":\"AmbassadorTest\"},\"name\":\"acceptancegrpcbridgetest-egrpc\",\"namespace\":\"default\"},\"spec\":{\"ports\":[{\"name\":\"http\",\"port\":80,\"protocol\":\"TCP\",\"targetPort\":8080},{\"name\":\"https\",\"port\":443,\"protocol\":\"TCP\",\"targetPort\":8443}],\"selector\":{\"backend\":\"acceptancegrpcbridgetest-egrpc\"}}}\n"
},
"creationTimestamp": "2020-01-10T16:54:06Z",
"creationTimestamp": "2020-01-13T06:08:46Z",
"labels": {
"kat-ambassador-id": "acceptancegrpcbridgetest",
"scope": "AmbassadorTest",
"service": "acceptancegrpcbridgetest-admin"
"scope": "AmbassadorTest"
},
"name": "acceptancegrpcbridgetest-admin",
"name": "acceptancegrpcbridgetest-egrpc",
"namespace": "default",
"resourceVersion": "59410",
"selfLink": "/api/v1/namespaces/default/services/acceptancegrpcbridgetest-admin",
"uid": "d02a4dc1-33c9-11ea-966c-16b58b03f3a1"
"resourceVersion": "34105",
"selfLink": "/api/v1/namespaces/default/services/acceptancegrpcbridgetest-egrpc",
"uid": "28754b58-35cb-11ea-83a4-122f10fc3771"
},
"spec": {
"clusterIP": "10.110.86.253",
"externalTrafficPolicy": "Cluster",
"clusterIP": "10.110.128.128",
"ports": [
{
"name": "acceptancegrpcbridgetest-admin",
"nodePort": 30470,
"port": 8877,
"name": "http",
"port": 80,
"protocol": "TCP",
"targetPort": 8877
"targetPort": 8080
},
{
"name": "https",
"port": 443,
"protocol": "TCP",
"targetPort": 8443
}
],
"selector": {
"service": "acceptancegrpcbridgetest"
"backend": "acceptancegrpcbridgetest-egrpc"
},
"sessionAffinity": "None",
"type": "NodePort"
"type": "ClusterIP"
},
"status": {
"loadBalancer": {}
Expand All @@ -110,40 +105,45 @@
"kind": "Service",
"metadata": {
"annotations": {
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{},\"labels\":{\"kat-ambassador-id\":\"acceptancegrpcbridgetest\",\"scope\":\"AmbassadorTest\"},\"name\":\"acceptancegrpcbridgetest-egrpc\",\"namespace\":\"default\"},\"spec\":{\"ports\":[{\"name\":\"http\",\"port\":80,\"protocol\":\"TCP\",\"targetPort\":8080},{\"name\":\"https\",\"port\":443,\"protocol\":\"TCP\",\"targetPort\":8443}],\"selector\":{\"backend\":\"acceptancegrpcbridgetest-egrpc\"}}}\n"
"getambassador.io/config": "---\napiVersion: ambassador/v0\nkind: Module\nname: ambassador\nconfig:\n enable_grpc_http11_bridge: True\nambassador_id: acceptancegrpcbridgetest\n\n---\napiVersion: ambassador/v0\nkind: Mapping\ngrpc: True\nprefix: /echo.EchoService/\nrewrite: /echo.EchoService/\nname: acceptancegrpcbridgetest-egrpc\nservice: acceptancegrpcbridgetest-egrpc\nambassador_id: acceptancegrpcbridgetest\n",
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{\"getambassador.io/config\":\"---\\napiVersion: ambassador/v0\\nkind: Module\\nname: ambassador\\nconfig:\\n enable_grpc_http11_bridge: True\\nambassador_id: acceptancegrpcbridgetest\\n\\n---\\napiVersion: ambassador/v0\\nkind: Mapping\\ngrpc: True\\nprefix: /echo.EchoService/\\nrewrite: /echo.EchoService/\\nname: acceptancegrpcbridgetest-egrpc\\nservice: acceptancegrpcbridgetest-egrpc\\nambassador_id: acceptancegrpcbridgetest\\n\"},\"labels\":{\"app.kubernetes.io/component\":\"ambassador-service\",\"kat-ambassador-id\":\"acceptancegrpcbridgetest\",\"scope\":\"AmbassadorTest\"},\"name\":\"acceptancegrpcbridgetest\",\"namespace\":\"default\"},\"spec\":{\"ports\":[{\"name\":\"http\",\"port\":80,\"protocol\":\"TCP\",\"targetPort\":8080},{\"name\":\"https\",\"port\":443,\"protocol\":\"TCP\",\"targetPort\":8443}],\"selector\":{\"service\":\"acceptancegrpcbridgetest\"},\"type\":\"NodePort\"}}\n"
},
"creationTimestamp": "2020-01-10T16:54:06Z",
"creationTimestamp": "2020-01-13T06:08:45Z",
"labels": {
"app.kubernetes.io/component": "ambassador-service",
"kat-ambassador-id": "acceptancegrpcbridgetest",
"scope": "AmbassadorTest"
},
"name": "acceptancegrpcbridgetest-egrpc",
"name": "acceptancegrpcbridgetest",
"namespace": "default",
"resourceVersion": "59423",
"selfLink": "/api/v1/namespaces/default/services/acceptancegrpcbridgetest-egrpc",
"uid": "d06cc729-33c9-11ea-966c-16b58b03f3a1"
"resourceVersion": "34091",
"selfLink": "/api/v1/namespaces/default/services/acceptancegrpcbridgetest",
"uid": "28588766-35cb-11ea-83a4-122f10fc3771"
},
"spec": {
"clusterIP": "10.97.183.137",
"clusterIP": "10.98.228.60",
"externalTrafficPolicy": "Cluster",
"ports": [
{
"name": "http",
"nodePort": 30059,
"port": 80,
"protocol": "TCP",
"targetPort": 8080
},
{
"name": "https",
"nodePort": 32113,
"port": 443,
"protocol": "TCP",
"targetPort": 8443
}
],
"selector": {
"backend": "acceptancegrpcbridgetest-egrpc"
"service": "acceptancegrpcbridgetest"
},
"sessionAffinity": "None",
"type": "ClusterIP"
"type": "NodePort"
},
"status": {
"loadBalancer": {}
Expand Down
Loading

0 comments on commit 06e770e

Please sign in to comment.