Allow terminating-gateway to setup listener before servicegroups are known

This commit is contained in:
freddygv 2020-04-14 15:13:25 -06:00
parent 929491c979
commit 3849b066a6
3 changed files with 16 additions and 3 deletions

View File

@ -2,7 +2,6 @@ package proxycfg
import ( import (
"context" "context"
"github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/agent/structs"
"github.com/mitchellh/copystructure" "github.com/mitchellh/copystructure"
) )

View File

@ -591,6 +591,20 @@ func (s *Server) makeTerminatingGatewayListener(name, addr string, port int, cfg
err = injectConnectFilters(cfgSnap, token, l, false) err = injectConnectFilters(cfgSnap, token, l, false)
// This fallback catch-all filter ensures a listener will be present for health checks to pass
// Envoy will reset these connections since known endpoints are caught by filter chain matches above
tcpProxy, err := makeTCPProxyFilter(name, "", "terminating_gateway_")
if err != nil {
return nil, err
}
fallback := envoylistener.FilterChain{
Filters: []envoylistener.Filter{
{Name: "envoy.filters.network.sni_cluster"},
tcpProxy,
},
}
l.FilterChains = append(l.FilterChains, fallback)
return l, nil return l, nil
} }

View File

@ -219,8 +219,8 @@ func (s *Server) process(stream ADSStream, reqCh <-chan *envoy.DiscoveryRequest)
resources: s.clustersFromSnapshot, resources: s.clustersFromSnapshot,
stream: stream, stream: stream,
allowEmptyFn: func(cfgSnap *proxycfg.ConfigSnapshot) bool { allowEmptyFn: func(cfgSnap *proxycfg.ConfigSnapshot) bool {
// Mesh gateways are allowed to inform CDS of no clusters. // Mesh and Terminating gateways are allowed to inform CDS of no clusters.
return cfgSnap.Kind == structs.ServiceKindMeshGateway return cfgSnap.Kind == structs.ServiceKindMeshGateway || cfgSnap.Kind == structs.ServiceKindTerminatingGateway
}, },
}, },
RouteType: { RouteType: {