mirror of
https://github.com/fluxcd/flagger.git
synced 2026-09-05 02:47:17 +00:00
adding BackendTimeout for Gateway API router
Signed-off-by: Danny Kulchinsky <dkulchinsky@fastly.com>
This commit is contained in:
@@ -168,6 +168,11 @@ type CanaryService struct {
|
||||
// +optional
|
||||
Timeout string `json:"timeout,omitempty"`
|
||||
|
||||
// BackendTimeout specifies a timeout for an individual request from the gateway
|
||||
// to a backend. Only supported by the Gateway API provider.
|
||||
// +optional
|
||||
BackendTimeout string `json:"backendTimeout,omitempty"`
|
||||
|
||||
// Gateways attached to the generated Istio virtual service
|
||||
// Defaults to the internal mesh gateway
|
||||
// +optional
|
||||
|
||||
+21
-20
@@ -108,11 +108,8 @@ func (gwr *GatewayAPIRouter) Reconcile(canary *flaggerv1.Canary) error {
|
||||
},
|
||||
},
|
||||
}
|
||||
if canary.Spec.Service.Timeout != "" {
|
||||
timeout := v1.Duration(canary.Spec.Service.Timeout)
|
||||
httpRouteSpec.Rules[0].Timeouts = &v1.HTTPRouteTimeouts{
|
||||
Request: &timeout,
|
||||
}
|
||||
if canary.Spec.Service.Timeout != "" || canary.Spec.Service.BackendTimeout != "" {
|
||||
httpRouteSpec.Rules[0].Timeouts = makeHTTPRouteTimeouts(canary)
|
||||
}
|
||||
|
||||
// A/B testing
|
||||
@@ -129,11 +126,8 @@ func (gwr *GatewayAPIRouter) Reconcile(canary *flaggerv1.Canary) error {
|
||||
},
|
||||
},
|
||||
})
|
||||
if canary.Spec.Service.Timeout != "" {
|
||||
timeout := v1.Duration(canary.Spec.Service.Timeout)
|
||||
httpRouteSpec.Rules[1].Timeouts = &v1.HTTPRouteTimeouts{
|
||||
Request: &timeout,
|
||||
}
|
||||
if canary.Spec.Service.Timeout != "" || canary.Spec.Service.BackendTimeout != "" {
|
||||
httpRouteSpec.Rules[1].Timeouts = makeHTTPRouteTimeouts(canary)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,11 +376,8 @@ func (gwr *GatewayAPIRouter) SetRoutes(
|
||||
},
|
||||
},
|
||||
}
|
||||
if canary.Spec.Service.Timeout != "" {
|
||||
timeout := v1.Duration(canary.Spec.Service.Timeout)
|
||||
weightedRouteRule.Timeouts = &v1.HTTPRouteTimeouts{
|
||||
Request: &timeout,
|
||||
}
|
||||
if canary.Spec.Service.Timeout != "" || canary.Spec.Service.BackendTimeout != "" {
|
||||
weightedRouteRule.Timeouts = makeHTTPRouteTimeouts(canary)
|
||||
}
|
||||
|
||||
// If B/G mirroring is enabled, then add a route filter which mirrors the traffic
|
||||
@@ -439,11 +430,8 @@ func (gwr *GatewayAPIRouter) SetRoutes(
|
||||
},
|
||||
})
|
||||
|
||||
if canary.Spec.Service.Timeout != "" {
|
||||
timeout := v1.Duration(canary.Spec.Service.Timeout)
|
||||
hrClone.Spec.Rules[1].Timeouts = &v1.HTTPRouteTimeouts{
|
||||
Request: &timeout,
|
||||
}
|
||||
if canary.Spec.Service.Timeout != "" || canary.Spec.Service.BackendTimeout != "" {
|
||||
hrClone.Spec.Rules[1].Timeouts = makeHTTPRouteTimeouts(canary)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -711,6 +699,19 @@ func (gwr *GatewayAPIRouter) mapRouteMatches(requestMatches []istiov1beta1.HTTPM
|
||||
return matches, nil
|
||||
}
|
||||
|
||||
func makeHTTPRouteTimeouts(canary *flaggerv1.Canary) *v1.HTTPRouteTimeouts {
|
||||
timeouts := &v1.HTTPRouteTimeouts{}
|
||||
if canary.Spec.Service.Timeout != "" {
|
||||
timeout := v1.Duration(canary.Spec.Service.Timeout)
|
||||
timeouts.Request = &timeout
|
||||
}
|
||||
if canary.Spec.Service.BackendTimeout != "" {
|
||||
backendTimeout := v1.Duration(canary.Spec.Service.BackendTimeout)
|
||||
timeouts.BackendRequest = &backendTimeout
|
||||
}
|
||||
return timeouts
|
||||
}
|
||||
|
||||
func (gwr *GatewayAPIRouter) makeBackendRef(svcName string, weight, port int32) v1.BackendRef {
|
||||
return v1.BackendRef{
|
||||
BackendObjectReference: v1.BackendObjectReference{
|
||||
|
||||
@@ -61,6 +61,7 @@ func TestGatewayAPIRouter_Reconcile(t *testing.T) {
|
||||
|
||||
timeout := routeRules[0].Timeouts
|
||||
assert.Equal(t, string(*timeout.Request), canary.Spec.Service.Timeout)
|
||||
assert.Equal(t, string(*timeout.BackendRequest), canary.Spec.Service.BackendTimeout)
|
||||
|
||||
// assert that http route annotations injected by the networking controller is preserved.
|
||||
httpRoute.Annotations["foo"] = "bar"
|
||||
|
||||
@@ -593,7 +593,8 @@ func newTestGatewayAPICanary() *flaggerv1.Canary {
|
||||
Name: "podinfo",
|
||||
},
|
||||
},
|
||||
Timeout: "10s",
|
||||
Timeout: "10s",
|
||||
BackendTimeout: "5s",
|
||||
},
|
||||
Analysis: &flaggerv1.CanaryAnalysis{
|
||||
Threshold: 10,
|
||||
|
||||
Reference in New Issue
Block a user