Skip to content

Commit

Permalink
fix: the timeout on HTTPRoute overwrites the timeout on BTP
Browse files Browse the repository at this point in the history
Signed-off-by: Kensei Nakada <handbomusic@gmail.com>
  • Loading branch information
sanposhiho committed Oct 5, 2024
1 parent 9214d8d commit 087d441
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
16 changes: 7 additions & 9 deletions internal/gatewayapi/clustersettings.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ func translateTrafficFeatures(policy *egv1a1.ClusterSettings) (*ir.TrafficFeatur
return ret, nil
}

func buildClusterSettingsTimeout(policy egv1a1.ClusterSettings, traffic *ir.TrafficFeatures) (*ir.Timeout, error) {
func buildClusterSettingsTimeout(policy egv1a1.ClusterSettings, routeTrafficFeatures *ir.TrafficFeatures) (*ir.Timeout, error) {
if policy.Timeout == nil {
if traffic != nil {
if routeTrafficFeatures != nil {
// Don't lose any existing timeout definitions.
return mergeTimeoutSettings(nil, traffic.Timeout), nil
return mergeTimeoutSettings(nil, routeTrafficFeatures.Timeout), nil
}
return nil, nil
}
Expand Down Expand Up @@ -145,13 +145,11 @@ func buildClusterSettingsTimeout(policy egv1a1.ClusterSettings, traffic *ir.Traf
}
}

// http request timeout is translated during the gateway-api route resource translation
// merge route timeout setting with backendtrafficpolicy timeout settings.
// Merging is done after the clustersettings definitions are translated so that
// clustersettings will override previous settings.
if traffic != nil {
to = mergeTimeoutSettings(to, traffic.Timeout)
// The timeout from route's TrafficFeatures takes precedence over the timeout in BTP
if routeTrafficFeatures != nil {
to = mergeTimeoutSettings(routeTrafficFeatures.Timeout, to)
}

return to, errs
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ httpRoutes:
backendRefs:
- name: service-1
port: 8080
timeouts:
request: 1s
backendTrafficPolicies:
- apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ httpRoutes:
- backendRefs:
- name: service-1
port: 8080
timeouts:
request: 1s
matches:
- path:
value: /
Expand Down Expand Up @@ -339,6 +341,6 @@ xdsIR:
http:
connectionIdleTimeout: 21s
maxConnectionDuration: 22s
requestTimeout: 23s
requestTimeout: 1s # Overwritten by the request timeout in HTTPRoute

Check warning on line 344 in internal/gatewayapi/testdata/backendtrafficpolicy-with-timeout.out.yaml

View workflow job for this annotation

GitHub Actions / lint

344:34 [comments] too few spaces before comment

Check warning on line 344 in internal/gatewayapi/testdata/backendtrafficpolicy-with-timeout.out.yaml

View workflow job for this annotation

GitHub Actions / lint

344:34 [comments] too few spaces before comment
tcp:
connectTimeout: 20s

0 comments on commit 087d441

Please sign in to comment.