mirror of https://github.com/hashicorp/consul
Leverage ServiceResolver ConnectTimeout for route timeouts to make TerminatingGateway upstream timeouts configurable
parent
4f8594b28f
commit
29768f27aa
|
@ -218,7 +218,7 @@ func (s *ResourceGenerator) makeRoutes(
|
||||||
if resolver.LoadBalancer != nil {
|
if resolver.LoadBalancer != nil {
|
||||||
lb = resolver.LoadBalancer
|
lb = resolver.LoadBalancer
|
||||||
}
|
}
|
||||||
route, err := makeNamedDefaultRouteWithLB(clusterName, lb, autoHostRewrite)
|
route, err := makeNamedDefaultRouteWithLB(clusterName, lb, resolver.ConnectTimeout, autoHostRewrite)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.Logger.Error("failed to make route", "cluster", clusterName, "error", err)
|
s.Logger.Error("failed to make route", "cluster", clusterName, "error", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -228,7 +228,7 @@ func (s *ResourceGenerator) makeRoutes(
|
||||||
// If there is a service-resolver for this service then also setup routes for each subset
|
// If there is a service-resolver for this service then also setup routes for each subset
|
||||||
for name := range resolver.Subsets {
|
for name := range resolver.Subsets {
|
||||||
clusterName = connect.ServiceSNI(svc.Name, name, svc.NamespaceOrDefault(), svc.PartitionOrDefault(), cfgSnap.Datacenter, cfgSnap.Roots.TrustDomain)
|
clusterName = connect.ServiceSNI(svc.Name, name, svc.NamespaceOrDefault(), svc.PartitionOrDefault(), cfgSnap.Datacenter, cfgSnap.Roots.TrustDomain)
|
||||||
route, err := makeNamedDefaultRouteWithLB(clusterName, lb, true)
|
route, err := makeNamedDefaultRouteWithLB(clusterName, lb, resolver.ConnectTimeout, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.Logger.Error("failed to make route", "cluster", clusterName, "error", err)
|
s.Logger.Error("failed to make route", "cluster", clusterName, "error", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -282,7 +282,7 @@ func (s *ResourceGenerator) routesForMeshGateway(cfgSnap *proxycfg.ConfigSnapsho
|
||||||
return resources, nil
|
return resources, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeNamedDefaultRouteWithLB(clusterName string, lb *structs.LoadBalancer, autoHostRewrite bool) (*envoy_route_v3.RouteConfiguration, error) {
|
func makeNamedDefaultRouteWithLB(clusterName string, lb *structs.LoadBalancer, timeout time.Duration, autoHostRewrite bool) (*envoy_route_v3.RouteConfiguration, error) {
|
||||||
action := makeRouteActionFromName(clusterName)
|
action := makeRouteActionFromName(clusterName)
|
||||||
|
|
||||||
if err := injectLBToRouteAction(lb, action.Route); err != nil {
|
if err := injectLBToRouteAction(lb, action.Route); err != nil {
|
||||||
|
@ -296,6 +296,10 @@ func makeNamedDefaultRouteWithLB(clusterName string, lb *structs.LoadBalancer, a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if timeout != 0 {
|
||||||
|
action.Route.Timeout = durationpb.New(timeout)
|
||||||
|
}
|
||||||
|
|
||||||
return &envoy_route_v3.RouteConfiguration{
|
return &envoy_route_v3.RouteConfiguration{
|
||||||
Name: clusterName,
|
Name: clusterName,
|
||||||
VirtualHosts: []*envoy_route_v3.VirtualHost{
|
VirtualHosts: []*envoy_route_v3.VirtualHost{
|
||||||
|
@ -637,6 +641,9 @@ func (s *ResourceGenerator) makeUpstreamRouteForDiscoveryChain(
|
||||||
return nil, fmt.Errorf("failed to apply load balancer configuration to route action: %v", err)
|
return nil, fmt.Errorf("failed to apply load balancer configuration to route action: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if startNode.Resolver.ConnectTimeout > 0 {
|
||||||
|
routeAction.Route.Timeout = durationpb.New(startNode.Resolver.ConnectTimeout)
|
||||||
|
}
|
||||||
defaultRoute := &envoy_route_v3.Route{
|
defaultRoute := &envoy_route_v3.Route{
|
||||||
Match: makeDefaultRouteMatch(),
|
Match: makeDefaultRouteMatch(),
|
||||||
Action: routeAction,
|
Action: routeAction,
|
||||||
|
|
Loading…
Reference in New Issue