mirror of https://github.com/status-im/consul.git
connect: Allow upstream listener escape hatch for prepared queries (#11109)
This commit is contained in:
parent
706fc8bcd0
commit
f972048ebc
|
@ -0,0 +1,3 @@
|
||||||
|
```release-note:bug
|
||||||
|
connect: Fix upstream listener escape hatch for prepared queries
|
||||||
|
```
|
|
@ -252,6 +252,20 @@ func (s *ResourceGenerator) listenersFromSnapshotConnectProxy(cfgSnap *proxycfg.
|
||||||
// default config if there is an error so it's safe to continue.
|
// default config if there is an error so it's safe to continue.
|
||||||
s.Logger.Warn("failed to parse", "upstream", u.Identifier(), "error", err)
|
s.Logger.Warn("failed to parse", "upstream", u.Identifier(), "error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If escape hatch is present, create a listener from it and move on to the next
|
||||||
|
if cfg.EnvoyListenerJSON != "" {
|
||||||
|
upstreamListener, err := makeListenerFromUserConfig(cfg.EnvoyListenerJSON)
|
||||||
|
if err != nil {
|
||||||
|
s.Logger.Error("failed to parse envoy_listener_json",
|
||||||
|
"upstream", u.Identifier(),
|
||||||
|
"error", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
resources = append(resources, upstreamListener)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
upstreamListener := makeListener(id, u, envoy_core_v3.TrafficDirection_OUTBOUND)
|
upstreamListener := makeListener(id, u, envoy_core_v3.TrafficDirection_OUTBOUND)
|
||||||
|
|
||||||
filterChain, err := s.makeUpstreamFilterChainForDiscoveryChain(
|
filterChain, err := s.makeUpstreamFilterChainForDiscoveryChain(
|
||||||
|
|
|
@ -159,20 +159,30 @@ func TestListenersFromSnapshot(t *testing.T) {
|
||||||
name: "custom-upstream",
|
name: "custom-upstream",
|
||||||
create: proxycfg.TestConfigSnapshot,
|
create: proxycfg.TestConfigSnapshot,
|
||||||
setup: func(snap *proxycfg.ConfigSnapshot) {
|
setup: func(snap *proxycfg.ConfigSnapshot) {
|
||||||
snap.Proxy.Upstreams[0].Config["envoy_listener_json"] =
|
for i := range snap.Proxy.Upstreams {
|
||||||
customListenerJSON(t, customListenerJSONOptions{
|
if snap.Proxy.Upstreams[i].Config == nil {
|
||||||
Name: "custom-upstream",
|
snap.Proxy.Upstreams[i].Config = map[string]interface{}{}
|
||||||
})
|
}
|
||||||
|
snap.Proxy.Upstreams[i].Config["envoy_listener_json"] =
|
||||||
|
customListenerJSON(t, customListenerJSONOptions{
|
||||||
|
Name: snap.Proxy.Upstreams[i].Identifier() + ":custom-upstream",
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "custom-upstream-ignored-with-disco-chain",
|
name: "custom-upstream-ignored-with-disco-chain",
|
||||||
create: proxycfg.TestConfigSnapshotDiscoveryChainWithFailover,
|
create: proxycfg.TestConfigSnapshotDiscoveryChainWithFailover,
|
||||||
setup: func(snap *proxycfg.ConfigSnapshot) {
|
setup: func(snap *proxycfg.ConfigSnapshot) {
|
||||||
snap.Proxy.Upstreams[0].Config["envoy_listener_json"] =
|
for i := range snap.Proxy.Upstreams {
|
||||||
customListenerJSON(t, customListenerJSONOptions{
|
if snap.Proxy.Upstreams[i].Config == nil {
|
||||||
Name: "custom-upstream",
|
snap.Proxy.Upstreams[i].Config = map[string]interface{}{}
|
||||||
})
|
}
|
||||||
|
snap.Proxy.Upstreams[i].Config["envoy_listener_json"] =
|
||||||
|
customListenerJSON(t, customListenerJSONOptions{
|
||||||
|
Name: snap.Proxy.Upstreams[i].Identifier() + ":custom-upstream",
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"resources": [
|
"resources": [
|
||||||
{
|
{
|
||||||
"@type": "type.googleapis.com/envoy.config.listener.v3.Listener",
|
"@type": "type.googleapis.com/envoy.config.listener.v3.Listener",
|
||||||
"name": "custom-upstream",
|
"name": "db:custom-upstream",
|
||||||
"address": {
|
"address": {
|
||||||
"socketAddress": {
|
"socketAddress": {
|
||||||
"address": "11.11.11.11",
|
"address": "11.11.11.11",
|
||||||
|
@ -27,11 +27,11 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"@type": "type.googleapis.com/envoy.config.listener.v3.Listener",
|
"@type": "type.googleapis.com/envoy.config.listener.v3.Listener",
|
||||||
"name": "prepared_query:geo-cache:127.10.10.10:8181",
|
"name": "prepared_query:geo-cache:custom-upstream",
|
||||||
"address": {
|
"address": {
|
||||||
"socketAddress": {
|
"socketAddress": {
|
||||||
"address": "127.10.10.10",
|
"address": "11.11.11.11",
|
||||||
"portValue": 8181
|
"portValue": 11111
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"filterChains": [
|
"filterChains": [
|
||||||
|
@ -41,14 +41,13 @@
|
||||||
"name": "envoy.filters.network.tcp_proxy",
|
"name": "envoy.filters.network.tcp_proxy",
|
||||||
"typedConfig": {
|
"typedConfig": {
|
||||||
"@type": "type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy",
|
"@type": "type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy",
|
||||||
"statPrefix": "upstream.prepared_query_geo-cache",
|
"statPrefix": "foo-stats",
|
||||||
"cluster": "geo-cache.default.dc1.query.11111111-2222-3333-4444-555555555555.consul"
|
"cluster": "random-cluster"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"trafficDirection": "OUTBOUND"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"@type": "type.googleapis.com/envoy.config.listener.v3.Listener",
|
"@type": "type.googleapis.com/envoy.config.listener.v3.Listener",
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"resources": [
|
"resources": [
|
||||||
{
|
{
|
||||||
"@type": "type.googleapis.com/envoy.api.v2.Listener",
|
"@type": "type.googleapis.com/envoy.api.v2.Listener",
|
||||||
"name": "custom-upstream",
|
"name": "db:custom-upstream",
|
||||||
"address": {
|
"address": {
|
||||||
"socketAddress": {
|
"socketAddress": {
|
||||||
"address": "11.11.11.11",
|
"address": "11.11.11.11",
|
||||||
|
@ -27,11 +27,11 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"@type": "type.googleapis.com/envoy.api.v2.Listener",
|
"@type": "type.googleapis.com/envoy.api.v2.Listener",
|
||||||
"name": "prepared_query:geo-cache:127.10.10.10:8181",
|
"name": "prepared_query:geo-cache:custom-upstream",
|
||||||
"address": {
|
"address": {
|
||||||
"socketAddress": {
|
"socketAddress": {
|
||||||
"address": "127.10.10.10",
|
"address": "11.11.11.11",
|
||||||
"portValue": 8181
|
"portValue": 11111
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"filterChains": [
|
"filterChains": [
|
||||||
|
@ -41,14 +41,13 @@
|
||||||
"name": "envoy.filters.network.tcp_proxy",
|
"name": "envoy.filters.network.tcp_proxy",
|
||||||
"typedConfig": {
|
"typedConfig": {
|
||||||
"@type": "type.googleapis.com/envoy.config.filter.network.tcp_proxy.v2.TcpProxy",
|
"@type": "type.googleapis.com/envoy.config.filter.network.tcp_proxy.v2.TcpProxy",
|
||||||
"statPrefix": "upstream.prepared_query_geo-cache",
|
"statPrefix": "foo-stats",
|
||||||
"cluster": "geo-cache.default.dc1.query.11111111-2222-3333-4444-555555555555.consul"
|
"cluster": "random-cluster"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"trafficDirection": "OUTBOUND"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"@type": "type.googleapis.com/envoy.api.v2.Listener",
|
"@type": "type.googleapis.com/envoy.api.v2.Listener",
|
||||||
|
|
Loading…
Reference in New Issue