Skip to content

fix: apply TrafficPolicy timeouts per route at the vhost level#14374

Merged
davidjumani merged 2 commits into
kgateway-dev:mainfrom
puertomontt:fix-timeout-vhost
Jul 10, 2026
Merged

fix: apply TrafficPolicy timeouts per route at the vhost level#14374
davidjumani merged 2 commits into
kgateway-dev:mainfrom
puertomontt:fix-timeout-vhost

Conversation

@puertomontt

@puertomontt puertomontt commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Description

Follow-up to #14360. That PR moved TrafficPolicy retry from the vhost level to per route inside ApplyVhostPlugin, but only handled retry. TrafficPolicy timeouts (and the other route-action-level settings) were still silently dropped when a policy targeted a Gateway HTTP listener section.

The reason: an HTTP listener sharing a port attaches at the Envoy virtual-host level, and ApplyVhostPlugin never applied timeouts there. The policy reported as Accepted with attachedRoutes: 1, but no timeout was emitted on the route action, so it had no dataplane effect. Whole-Gateway and HTTPS-listener targeting were unaffected because they attach at the RouteConfiguration level (via applyGatewayLevelPerRouteSettings).

This generalizes the vhost path to apply the full per-route settings (timeouts, retries, url rewrite, internal redirect, auto host rewrite, route tracing) to every route in the vhost, via a shared applyPerRouteSettings helper that mirrors applyGatewayLevelPerRouteSettings. The existing "only set if not already set" guards in handlePerRoutePolicies preserve merge precedence (a more specific TrafficPolicy or builtin HTTPRoute policy still wins).

Also adds gateway-translator tests for TrafficPolicy timeout targeting the whole Gateway, an HTTP listener, and an HTTPS listener. Refreshing all goldens changed no existing output, confirming retry and every other behavior is unchanged.

Change Type

/kind fix

Changelog

Fixed a bug where a TrafficPolicy timeout (and other route-level settings) targeting a Gateway HTTP listener section was silently ignored.

A TrafficPolicy targeting a Gateway HTTP listener section attaches at the
Envoy virtual-host level. Timeouts (and other route-action-level settings)
are only applied per route, so they were silently dropped for such policies
even though the policy reported as Accepted. HTTPS listener and whole-Gateway
targeting were unaffected since they attach at the RouteConfiguration level.

Generalize ApplyVhostPlugin to apply the full per-route settings to every
route in the vhost via a shared applyPerRouteSettings helper, mirroring
applyGatewayLevelPerRouteSettings. The existing 'only set if not already set'
guards preserve merge precedence.

Add gateway translator tests for TrafficPolicy timeout targeting the whole
Gateway, an HTTP listener, and an HTTPS listener.

Signed-off-by: omar <[email protected]>
Copilot AI review requested due to automatic review settings July 9, 2026 16:02
@gateway-bot gateway-bot added do-not-merge/description-invalid kind/fix Categorizes issue or PR as related to a bug. release-note labels Jul 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes TrafficPolicy route-action settings (notably request timeouts, plus other per-route settings like retries, URL rewrite, internal redirect, auto host rewrite, and route tracing) being dropped when a TrafficPolicy targets a Gateway HTTP listener section (vhost-attached). It generalizes the vhost plugin path to apply the full set of per-route settings to each route in the virtual host, matching the existing gateway/HTTPS-listener (RouteConfiguration-attached) behavior.

Changes:

  • Introduces a shared applyPerRouteSettings helper and reuses it for both gateway-level and vhost-level policy application.
  • Updates ApplyVhostPlugin to apply all per-route TrafficPolicy settings per-route (instead of only retry).
  • Adds gateway translator golden tests covering TrafficPolicy request timeouts targeting: whole Gateway, HTTP listener section, and HTTPS listener section.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/kgateway/extensions2/plugins/trafficpolicy/traffic_policy_plugin.go Applies full TrafficPolicy per-route settings to each route for vhost-attached policies via a shared helper.
pkg/kgateway/translator/gateway/gateway_translator_test.go Adds translator test cases for whole-gateway, HTTP-listener, and HTTPS-listener timeout targeting scenarios.
pkg/kgateway/translator/gateway/testutils/inputs/traffic-policy/timeout-gateway-whole.yaml New input fixture for whole-Gateway timeout behavior across HTTP+HTTPS listeners.
pkg/kgateway/translator/gateway/testutils/inputs/traffic-policy/timeout-gateway-http-listener.yaml New input fixture for HTTP listener section timeout behavior.
pkg/kgateway/translator/gateway/testutils/inputs/traffic-policy/timeout-gateway-https-listener.yaml New input fixture for HTTPS listener section timeout behavior.
pkg/kgateway/translator/gateway/testutils/outputs/traffic-policy/timeout-gateway-whole.yaml New golden output validating whole-Gateway timeout emission on both listeners’ routes.
pkg/kgateway/translator/gateway/testutils/outputs/traffic-policy/timeout-gateway-http-listener.yaml New golden output validating HTTP-listener-section timeout emission on vhost routes.
pkg/kgateway/translator/gateway/testutils/outputs/traffic-policy/timeout-gateway-https-listener.yaml New golden output validating HTTPS-listener-section timeout emission on routes.

Add a gateway translator test where a Gateway HTTP listener timeout (30s) is
inherited by one route rule and overridden by a more specific route-level
TrafficPolicy timeout (5s) on another rule, mirroring listener-retry.yaml.
This exercises the override precedence through applyPerRouteSettings at the
vhost level.

Signed-off-by: omar <[email protected]>
@davidjumani
davidjumani added this pull request to the merge queue Jul 10, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 10, 2026
@davidjumani
davidjumani added this pull request to the merge queue Jul 10, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 10, 2026
@davidjumani
davidjumani added this pull request to the merge queue Jul 10, 2026
Merged via the queue into kgateway-dev:main with commit e9b30cc Jul 10, 2026
35 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/fix Categorizes issue or PR as related to a bug. release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants