mirror of https://github.com/status-im/consul.git
Revert "Avoid accumulating synthetic upstreams"
This reverts commit 86672df4fa
.
This commit is contained in:
parent
86672df4fa
commit
a6388c7e2f
|
@ -326,7 +326,7 @@ func makeConfigRequest(bd BaseDeps, addReq AddServiceRequest) *structs.ServiceCo
|
||||||
// Also if we have any upstreams defined, add them to the request so we can
|
// Also if we have any upstreams defined, add them to the request so we can
|
||||||
// learn about their configs.
|
// learn about their configs.
|
||||||
for _, us := range ns.Proxy.Upstreams {
|
for _, us := range ns.Proxy.Upstreams {
|
||||||
if us.DestinationType == "" || us.DestinationType == structs.UpstreamDestTypeService && !us.CentrallyConfigured {
|
if us.DestinationType == "" || us.DestinationType == structs.UpstreamDestTypeService {
|
||||||
sid := us.DestinationID()
|
sid := us.DestinationID()
|
||||||
sid.EnterpriseMeta.Merge(&ns.EnterpriseMeta)
|
sid.EnterpriseMeta.Merge(&ns.EnterpriseMeta)
|
||||||
upstreams = append(upstreams, sid)
|
upstreams = append(upstreams, sid)
|
||||||
|
@ -440,25 +440,14 @@ func mergeServiceConfig(defaults *structs.ServiceConfigResponse, service *struct
|
||||||
// This does not apply outside of TransparentProxy mode because in that situation every possible upstream already exists
|
// This does not apply outside of TransparentProxy mode because in that situation every possible upstream already exists
|
||||||
// inside of ns.Proxy.Upstreams.
|
// inside of ns.Proxy.Upstreams.
|
||||||
if ns.Proxy.TransparentProxy {
|
if ns.Proxy.TransparentProxy {
|
||||||
var upstreams structs.Upstreams
|
|
||||||
|
|
||||||
for _, us := range ns.Proxy.Upstreams {
|
|
||||||
if _, ok := remoteUpstreams[us.DestinationID()]; !ok && us.CentrallyConfigured {
|
|
||||||
// If a centrally configured upstream is only present locally then that means it was
|
|
||||||
// removed from central config and should be removed from the local list as well.
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
upstreams = append(upstreams, us)
|
|
||||||
}
|
|
||||||
|
|
||||||
for id, remote := range remoteUpstreams {
|
for id, remote := range remoteUpstreams {
|
||||||
if _, ok := localUpstreams[id]; ok {
|
if _, ok := localUpstreams[id]; ok {
|
||||||
// Remote upstream is already present locally
|
// Remote upstream is already present locally
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
upstreams = append(upstreams, remote)
|
|
||||||
|
ns.Proxy.Upstreams = append(ns.Proxy.Upstreams, remote)
|
||||||
}
|
}
|
||||||
ns.Proxy.Upstreams = upstreams
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ns, err
|
return ns, err
|
||||||
|
|
|
@ -1047,64 +1047,6 @@ func Test_mergeServiceConfig_UpstreamOverrides(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "synthetic local upstream is cleaned up if not in config response",
|
|
||||||
args: args{
|
|
||||||
defaults: &structs.ServiceConfigResponse{
|
|
||||||
UpstreamIDConfigs: structs.OpaqueUpstreamConfigs{
|
|
||||||
{
|
|
||||||
Upstream: structs.ServiceID{
|
|
||||||
ID: "zap",
|
|
||||||
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
|
|
||||||
},
|
|
||||||
Config: map[string]interface{}{
|
|
||||||
"protocol": "grpc",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
service: &structs.NodeService{
|
|
||||||
ID: "foo-proxy",
|
|
||||||
Service: "foo-proxy",
|
|
||||||
Proxy: structs.ConnectProxyConfig{
|
|
||||||
DestinationServiceName: "foo",
|
|
||||||
DestinationServiceID: "foo",
|
|
||||||
TransparentProxy: true,
|
|
||||||
Upstreams: structs.Upstreams{
|
|
||||||
structs.Upstream{
|
|
||||||
DestinationNamespace: "default",
|
|
||||||
DestinationName: "zip",
|
|
||||||
LocalBindPort: 8080,
|
|
||||||
Config: map[string]interface{}{
|
|
||||||
"protocol": "http",
|
|
||||||
},
|
|
||||||
// Should get zip cleaned up
|
|
||||||
CentrallyConfigured: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
want: &structs.NodeService{
|
|
||||||
ID: "foo-proxy",
|
|
||||||
Service: "foo-proxy",
|
|
||||||
Proxy: structs.ConnectProxyConfig{
|
|
||||||
DestinationServiceName: "foo",
|
|
||||||
DestinationServiceID: "foo",
|
|
||||||
TransparentProxy: true,
|
|
||||||
Upstreams: structs.Upstreams{
|
|
||||||
structs.Upstream{
|
|
||||||
DestinationNamespace: "default",
|
|
||||||
DestinationName: "zap",
|
|
||||||
Config: map[string]interface{}{
|
|
||||||
"protocol": "grpc",
|
|
||||||
},
|
|
||||||
CentrallyConfigured: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "upstream mode from remote defaults overrides local default",
|
name: "upstream mode from remote defaults overrides local default",
|
||||||
args: args{
|
args: args{
|
||||||
|
|
Loading…
Reference in New Issue