Skip to content

Avoiding HTTP 504 errors for long-running upstream requests, with Gateway API #5159

@jdoylei

Description

@jdoylei

How can we configure timeouts in Contour - based on Gateway API objects - to avoid HTTP 504 "upstream request timeout" responses from Envoy when our upstream service is slow (response in > 15 seconds)?

Background:

We have Contour's Gateway provisioner installed, currently v1.23.0, so our apps can use Gateway API with dynamic provisioning.

We hit a road-block with a slow upstream service that exceeds 15 seconds and causes Envoy to respond with HTTP 504 "upstream request timeout". I think this means that the upstream service is exceeding Envoy's default 15-second route-level timeout.

I gleaned from the Gateway API guide that I could use ContourDeployment to set some configuration, including the runtimeSettings.envoy.timeouts block with e.g. timeouts.requestTimeout. And I verified using /config_dump that Envoy's config reflects these timeouts settings, e.g. request_timeout. But this requestTimeout/request_timeout is different from the route-level timeout in Envoy's config, and changing it doesn't seem to affect this 15-second limit. It doesn't seem that any of ContourDeployment impacts the route-level timeout.

Outside of Gateway API, it looks like there are different ways of setting the route-level timeout:

But I don't see a way using Gateway API and associated objects (GatewayClass, ContourDeployment, Gateway, HTTPRoute, Service) to set this.

How can we use Gateway API and still support a slow upstream service that takes > 15 seconds?

If there's not an immediate solution in the current Contour version, here are some thoughts:

  • Can ContourDeployment runtimeSettings.envoy.timeouts get a new field that gives a global value to apply as the route-level timeout for all Envoy routes?
  • Can Contour process the annotation projectcontour.io/response-timeout on Gateway, similar to what it does on Ingress? Or even on Service (since there are already Service Contour annotations that seem like they map to Envoy route config)?
  • Can Contour implement a policy CRD for settings like the route-level timeout along the lines of the Gateway policy attachment spec? E.g. we would create a ContourTimeoutPolicy with a setting response: '30s' and targetRef pointing to an HTTPRoute?

Thanks for your time!

Environment:

  • Contour version: v1.23.0
  • Kubernetes version: (use kubectl version): v1.23.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/gateway-apiIssues or PRs related to the Gateway (Gateway API working group) API.blocked/needs-gateway-apiCategorizes the issue or PR as blocked because it needs changes in Gateway API.kind/featureCategorizes issue or PR as related to a new feature.priority/important-soonMust be staffed and worked on either currently, or very soon, ideally in time for the next release.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions