mirror of https://github.com/linkerd/linkerd2.git
Update Go codegen for httproute timeout fields (#11164)
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 <ki@buoyant.io>
This commit is contained in:
parent
25ed8c2960
commit
32831ba501
|
@ -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.
|
Copyright 2020 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -15,8 +21,6 @@ limitations under the License.
|
||||||
package v1beta3
|
package v1beta3
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
|
gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
|
||||||
)
|
)
|
||||||
|
@ -229,10 +233,11 @@ type HTTPRouteRule struct {
|
||||||
|
|
||||||
// Timeouts defines the timeouts that can be configured for an HTTP request.
|
// Timeouts defines the timeouts that can be configured for an HTTP request.
|
||||||
//
|
//
|
||||||
// Support: Core
|
// Support: Extended
|
||||||
//
|
//
|
||||||
// +optional
|
// +optional
|
||||||
Timeouts HttpRouteTimeouts `json:"timeouts,omitempty"`
|
// <gateway:experimental>
|
||||||
|
Timeouts *HTTPRouteTimeouts `json:"timeouts,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PathMatchType specifies the semantics of how HTTP paths should be compared.
|
// PathMatchType specifies the semantics of how HTTP paths should be compared.
|
||||||
|
@ -485,6 +490,7 @@ const (
|
||||||
// headers:
|
// headers:
|
||||||
// - name: "version"
|
// - name: "version"
|
||||||
// value "v1"
|
// value "v1"
|
||||||
|
//
|
||||||
// ```
|
// ```
|
||||||
type HTTPRouteMatch struct {
|
type HTTPRouteMatch struct {
|
||||||
// Path specifies a HTTP request path matcher. If this field is not
|
// Path specifies a HTTP request path matcher. If this field is not
|
||||||
|
@ -814,34 +820,42 @@ type HTTPRouteStatus struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// HTTPRouteTimeouts defines timeouts that can be configured for an HTTPRoute.
|
// HTTPRouteTimeouts defines timeouts that can be configured for an HTTPRoute.
|
||||||
// Timeout values are formatted like 1h/1m/1s/1ms as parsed by Golang
|
// Timeout values are formatted like 1h/1m/1s/1ms as parsed by Golang time.ParseDuration
|
||||||
// time.ParseDuration and MUST BE >= 1ms.
|
// and MUST BE >= 1ms or 0 to disable (no timeout).
|
||||||
type HttpRouteTimeouts struct {
|
type HTTPRouteTimeouts struct {
|
||||||
// Request specifies a timeout for the Gateway to send a response to a client
|
// Request specifies the duration for processing an HTTP client request after which the
|
||||||
// HTTP request. Whether the gateway starts the timeout before or after the
|
// gateway will time out if unable to send a response.
|
||||||
// entire client request stream has been received, is implementation
|
|
||||||
// dependent.
|
|
||||||
//
|
//
|
||||||
// For example, setting the `rules.timeouts.request` field to the value `10s`
|
// For example, setting this field to the value `10s` in an HTTPRoute will cause
|
||||||
// in an `HTTPRoute` will cause a timeout if a client request is taking longer
|
// a timeout if a client request is taking longer than 10 seconds to complete.
|
||||||
// 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.
|
||||||
//
|
|
||||||
// +optional
|
|
||||||
Request *time.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.
|
|
||||||
//
|
|
||||||
// The value of BackendRequest defaults to and must be <= the value of Request
|
|
||||||
// timeout.
|
|
||||||
//
|
//
|
||||||
// Support: Extended
|
// Support: Extended
|
||||||
//
|
//
|
||||||
// +optional
|
// +optional
|
||||||
BackendRequest *time.Duration `json:"backendRequest,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. 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.
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
// +kubebuilder:validation:Format=duration
|
||||||
|
BackendRequest *metav1.Duration `json:"backendRequest,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,7 @@ limitations under the License.
|
||||||
package v1beta3
|
package v1beta3
|
||||||
|
|
||||||
import (
|
import (
|
||||||
time "time"
|
"k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||||
v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
|
v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
|
||||||
)
|
)
|
||||||
|
@ -361,7 +360,11 @@ func (in *HTTPRouteRule) DeepCopyInto(out *HTTPRouteRule) {
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
in.Timeouts.DeepCopyInto(&out.Timeouts)
|
if in.Timeouts != nil {
|
||||||
|
in, out := &in.Timeouts, &out.Timeouts
|
||||||
|
*out = new(HTTPRouteTimeouts)
|
||||||
|
(*in).DeepCopyInto(*out)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,27 +425,26 @@ func (in *HTTPRouteStatus) DeepCopy() *HTTPRouteStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
func (in *HttpRouteTimeouts) DeepCopyInto(out *HttpRouteTimeouts) {
|
func (in *HTTPRouteTimeouts) DeepCopyInto(out *HTTPRouteTimeouts) {
|
||||||
*out = *in
|
*out = *in
|
||||||
if in.Request != nil {
|
if in.Request != nil {
|
||||||
in, out := &in.Request, &out.Request
|
in, out := &in.Request, &out.Request
|
||||||
*out = new(time.Duration)
|
*out = new(v1.Duration)
|
||||||
**out = **in
|
**out = **in
|
||||||
}
|
}
|
||||||
if in.BackendRequest != nil {
|
if in.BackendRequest != nil {
|
||||||
in, out := &in.BackendRequest, &out.BackendRequest
|
in, out := &in.BackendRequest, &out.BackendRequest
|
||||||
*out = new(time.Duration)
|
*out = new(v1.Duration)
|
||||||
**out = **in
|
**out = **in
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HttpRouteTimeouts.
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPRouteTimeouts.
|
||||||
func (in *HttpRouteTimeouts) DeepCopy() *HttpRouteTimeouts {
|
func (in *HTTPRouteTimeouts) DeepCopy() *HTTPRouteTimeouts {
|
||||||
if in == nil {
|
if in == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
out := new(HttpRouteTimeouts)
|
out := new(HTTPRouteTimeouts)
|
||||||
in.DeepCopyInto(out)
|
in.DeepCopyInto(out)
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue