Skip to content

Commit

Permalink
Enable websocket upgrades for connect listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
mattclement authored and chrisboulton committed Jan 4, 2023
1 parent 6f3ee22 commit ebbb7c1
Show file tree
Hide file tree
Showing 44 changed files with 425 additions and 69 deletions.
19 changes: 12 additions & 7 deletions agent/xds/listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -1644,13 +1644,13 @@ func (s *ResourceGenerator) makeFilterChainTerminatingGateway(cfgSnap *proxycfg.
// HTTP filter to do intention checks here instead.
timeout := 0
opts := listenerFilterOpts{
protocol: tgtwyOpts.protocol,
filterName: fmt.Sprintf("%s.%s.%s.%s", tgtwyOpts.service.Name, tgtwyOpts.service.NamespaceOrDefault(), tgtwyOpts.service.PartitionOrDefault(), cfgSnap.Datacenter),
routeName: tgtwyOpts.cluster, // Set cluster name for route config since each will have its own
cluster: tgtwyOpts.cluster,
statPrefix: "upstream.",
routePath: "",
tracing: tracing,
protocol: tgtwyOpts.protocol,
filterName: fmt.Sprintf("%s.%s.%s.%s", tgtwyOpts.service.Name, tgtwyOpts.service.NamespaceOrDefault(), tgtwyOpts.service.PartitionOrDefault(), cfgSnap.Datacenter),
routeName: tgtwyOpts.cluster, // Set cluster name for route config since each will have its own
cluster: tgtwyOpts.cluster,
statPrefix: "upstream.",
routePath: "",
tracing: tracing,
requestTimeoutMs: &timeout,
}

Expand Down Expand Up @@ -2209,6 +2209,11 @@ func makeHTTPFilter(opts listenerFilterOpts) (*envoy_listener_v3.Filter, error)
HttpFilters: []*envoy_http_v3.HttpFilter{
router,
},
UpgradeConfigs: []*envoy_http_v3.HttpConnectionManager_UpgradeConfig{
{
UpgradeType: "websocket",
},
},
Tracing: &envoy_http_v3.HttpConnectionManager_Tracing{
// Don't trace any requests by default unless the client application
// explicitly propagates trace headers that indicate this should be
Expand Down
6 changes: 6 additions & 0 deletions agent/xds/listeners_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,12 @@ const customHTTPListenerJSONTpl = `{
"name": "envoy.filters.http.router"
}
],
"upgrade_configs": [
{
"upgrade_type": "websocket"
}
],
"route_config": {
"name": "public_listener",
"virtual_hosts": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@
},
"http2ProtocolOptions": {

}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@
},
"http2ProtocolOptions": {

}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@
"randomSampling": {

}
}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@
},
"http2ProtocolOptions": {

}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
{
"name": "envoy.filters.http.router"
}
],
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
{
"name": "envoy.filters.http.router"
}
],
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,12 @@
"chain": true,
"dns": true,
"uri": true
}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
],
Expand Down
7 changes: 6 additions & 1 deletion agent/xds/testdata/listeners/expose-checks.latest.golden
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@
"randomSampling": {

}
}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@
"randomSampling": {

}
}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
]
Expand Down Expand Up @@ -109,7 +114,12 @@
"randomSampling": {

}
}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@
},
"http2ProtocolOptions": {

}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
]
Expand Down Expand Up @@ -112,7 +117,12 @@
"randomSampling": {

}
}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,12 @@
"chain": true,
"dns": true,
"uri": true
}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,12 @@
"chain": true,
"dns": true,
"uri": true
}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@
"randomSampling": {

}
}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@
"chain": true,
"dns": true,
"uri": true
}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
],
Expand Down
7 changes: 6 additions & 1 deletion agent/xds/testdata/listeners/http-upstream.latest.golden
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@
"randomSampling": {

}
}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@
"chain": true,
"dns": true,
"uri": true
}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@
},
"http2ProtocolOptions": {

}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@
"randomSampling": {

}
}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
]
Expand Down Expand Up @@ -85,7 +90,12 @@
"randomSampling": {

}
}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@
"randomSampling": {

}
}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@
},
"http2ProtocolOptions": {

}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
]
Expand Down Expand Up @@ -117,7 +122,12 @@
},
"http2ProtocolOptions": {

}
},
"upgradeConfigs": [
{
"upgradeType": "websocket"
}
]
}
}
],
Expand Down
Loading

0 comments on commit ebbb7c1

Please sign in to comment.