Skip to content

Commit

Permalink
Update Go codegen for httproute timeout fields
Browse files Browse the repository at this point in the history
In #11008 I added Go support for the `timeouts` field in the
`HTTPRouteRule` struct. That used Go's built-in `time.Duration` type,
but based on my reading of kubernetes-sigs/gateway-api#2013, we should
instead by using apimachinery's `metav1.Duration` type.

Signed-off-by: Kevin Ingelman <[email protected]>
  • Loading branch information
klingerf committed Jul 24, 2023
1 parent 25ed8c2 commit f159041
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 34 deletions.
62 changes: 38 additions & 24 deletions controller/gen/apis/policy/v1beta3/httproute.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
/*
Adapted from https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1alpha2/httproute_types.go
Adapted from:
- https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1alpha2/httproute_types.go
- https://github.com/kubernetes-sigs/gateway-api/pull/2013
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -15,8 +21,6 @@ limitations under the License.
package v1beta3

import (
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
)
Expand Down Expand Up @@ -229,10 +233,11 @@ type HTTPRouteRule struct {

// Timeouts defines the timeouts that can be configured for an HTTP request.
//
// Support: Core
// Support: Extended
//
// +optional
Timeouts HttpRouteTimeouts `json:"timeouts,omitempty"`
// <gateway:experimental>
Timeouts *HTTPRouteTimeouts `json:"timeouts,omitempty"`
}

// PathMatchType specifies the semantics of how HTTP paths should be compared.
Expand Down Expand Up @@ -485,6 +490,7 @@ const (
// headers:
// - name: "version"
// value "v1"
//
// ```
type HTTPRouteMatch struct {
// Path specifies a HTTP request path matcher. If this field is not
Expand Down Expand Up @@ -814,34 +820,42 @@ type HTTPRouteStatus struct {
}

// HTTPRouteTimeouts defines timeouts that can be configured for an HTTPRoute.
// Timeout values are formatted like 1h/1m/1s/1ms as parsed by Golang
// time.ParseDuration and MUST BE >= 1ms.
type HttpRouteTimeouts struct {
// Request specifies a timeout for the Gateway to send a response to a client
// HTTP request. Whether the gateway starts the timeout before or after the
// entire client request stream has been received, is implementation
// dependent.
// Timeout values are formatted like 1h/1m/1s/1ms as parsed by Golang time.ParseDuration
// and MUST BE >= 1ms or 0 to disable (no timeout).
type HTTPRouteTimeouts struct {
// Request specifies the duration for processing an HTTP client request after which the
// gateway will time out if unable to send a response.
//
// For example, setting the `rules.timeouts.request` field to the value `10s`
// in an `HTTPRoute` will cause a timeout if a client request is taking longer
// than 10 seconds to complete.
// For example, setting this field to the value `10s` in an HTTPRoute will cause
// a timeout if a client request is taking longer than 10 seconds to complete.
//
// Request timeouts are disabled by default.
// This timeout is intended to cover as close to the whole request-response transaction
// as possible although an implementation MAY choose to start the timeout after the entire
// request stream has been received instead of immediately after the transaction is
// initiated by the client.
//
// Support: Core
// When this field is unspecified, request timeout behavior is implementation-dependent.
//
// Support: Extended
//
// +optional
Request *time.Duration `json:"request,omitempty"`
// +kubebuilder:validation:Format=duration
Request *metav1.Duration `json:"request,omitempty"`

// BackendRequest specifies a timeout for an individual request from the
// gateway to a backend service. Typically used in conjunction with retry
// configuration, if supported by an implementation.
// BackendRequest specifies a timeout for an individual request from the gateway
// to a backend service. This covers the time from when the request first starts being
// sent from the gateway to when the full response has been received from the backend.
//
// An entire client HTTP transaction with a gateway, covered by the Request timeout,
// may result in more than one call from the gateway to the destination backend service,
// for example, if automatic retries are supported.
//
// The value of BackendRequest defaults to and must be <= the value of Request
// timeout.
// Because the Request timeout encompasses the BackendRequest timeout,
// the value of BackendRequest defaults to and must be <= the value of Request timeout.
//
// Support: Extended
//
// +optional
BackendRequest *time.Duration `json:"backendRequest,omitempty"`
// +kubebuilder:validation:Format=duration
BackendRequest *metav1.Duration `json:"backendRequest,omitempty"`
}
22 changes: 12 additions & 10 deletions controller/gen/apis/policy/v1beta3/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f159041

Please sign in to comment.