feat: add readIdleTimeout and pingTimeout config options to ServersTransport
Co-authored-by: Kevin Pollet <pollet.kevin@gmail.com>
This commit is contained in:
parent
8e32d1913b
commit
1f17731369
14 changed files with 204 additions and 38 deletions
|
@ -110,6 +110,8 @@ spec:
|
|||
dialTimeout: 42
|
||||
responseHeaderTimeout: 42s
|
||||
idleConnTimeout: 42ms
|
||||
readIdleTimeout: 42s
|
||||
pingTimeout: 42s
|
||||
|
||||
---
|
||||
apiVersion: traefik.containo.us/v1alpha1
|
||||
|
|
|
@ -340,6 +340,20 @@ func (p *Provider) loadConfigurationFromCRD(ctx context.Context, client Client)
|
|||
logger.Errorf("Error while reading IdleConnTimeout: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if serversTransport.Spec.ForwardingTimeouts.ReadIdleTimeout != nil {
|
||||
err := forwardingTimeout.ReadIdleTimeout.Set(serversTransport.Spec.ForwardingTimeouts.ReadIdleTimeout.String())
|
||||
if err != nil {
|
||||
logger.Errorf("Error while reading ReadIdleTimeout: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if serversTransport.Spec.ForwardingTimeouts.PingTimeout != nil {
|
||||
err := forwardingTimeout.PingTimeout.Set(serversTransport.Spec.ForwardingTimeouts.PingTimeout.String())
|
||||
if err != nil {
|
||||
logger.Errorf("Error while reading PingTimeout: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
id := provider.Normalize(makeID(serversTransport.Namespace, serversTransport.Name))
|
||||
|
|
|
@ -3618,6 +3618,8 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
DialTimeout: ptypes.Duration(42 * time.Second),
|
||||
ResponseHeaderTimeout: ptypes.Duration(42 * time.Second),
|
||||
IdleConnTimeout: ptypes.Duration(42 * time.Millisecond),
|
||||
ReadIdleTimeout: ptypes.Duration(42 * time.Second),
|
||||
PingTimeout: ptypes.Duration(42 * time.Second),
|
||||
},
|
||||
PeerCertURI: "foo://bar",
|
||||
},
|
||||
|
@ -3626,6 +3628,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
ForwardingTimeouts: &dynamic.ForwardingTimeouts{
|
||||
DialTimeout: ptypes.Duration(30 * time.Second),
|
||||
IdleConnTimeout: ptypes.Duration(90 * time.Second),
|
||||
PingTimeout: ptypes.Duration(15 * time.Second),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -4873,6 +4876,8 @@ func TestCrossNamespace(t *testing.T) {
|
|||
DialTimeout: 30000000000,
|
||||
ResponseHeaderTimeout: 0,
|
||||
IdleConnTimeout: 90000000000,
|
||||
ReadIdleTimeout: 0,
|
||||
PingTimeout: 15000000000,
|
||||
},
|
||||
DisableHTTP2: true,
|
||||
},
|
||||
|
@ -4904,6 +4909,8 @@ func TestCrossNamespace(t *testing.T) {
|
|||
DialTimeout: 30000000000,
|
||||
ResponseHeaderTimeout: 0,
|
||||
IdleConnTimeout: 90000000000,
|
||||
ReadIdleTimeout: 0,
|
||||
PingTimeout: 15000000000,
|
||||
},
|
||||
DisableHTTP2: true,
|
||||
},
|
||||
|
|
|
@ -43,13 +43,17 @@ type ServersTransportSpec struct {
|
|||
|
||||
// ForwardingTimeouts contains timeout configurations for forwarding requests to the backend servers.
|
||||
type ForwardingTimeouts struct {
|
||||
// The amount of time to wait until a connection to a backend server can be established. If zero, no timeout exists.
|
||||
// DialTimeout is the amount of time to wait until a connection to a backend server can be established. If zero, no timeout exists.
|
||||
DialTimeout *intstr.IntOrString `json:"dialTimeout,omitempty"`
|
||||
// The amount of time to wait for a server's response headers after fully writing the request (including its body, if any).
|
||||
// ResponseHeaderTimeout is the amount of time to wait for a server's response headers after fully writing the request (including its body, if any).
|
||||
// If zero, no timeout exists.
|
||||
ResponseHeaderTimeout *intstr.IntOrString `json:"responseHeaderTimeout,omitempty"`
|
||||
// The maximum period for which an idle HTTP keep-alive connection will remain open before closing itself.
|
||||
// IdleConnTimeout is the maximum period for which an idle HTTP keep-alive connection will remain open before closing itself.
|
||||
IdleConnTimeout *intstr.IntOrString `json:"idleConnTimeout,omitempty"`
|
||||
// ReadIdleTimeout is the timeout after which a health check using ping frame will be carried out if no frame is received on the HTTP/2 connection. If zero, no health check is performed.
|
||||
ReadIdleTimeout *intstr.IntOrString `json:"readIdleTimeout,omitempty"`
|
||||
// PingTimeout is the timeout after which the HTTP/2 connection will be closed if a response to ping is not received.
|
||||
PingTimeout *intstr.IntOrString `json:"pingTimeout,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
|
|
@ -214,6 +214,16 @@ func (in *ForwardingTimeouts) DeepCopyInto(out *ForwardingTimeouts) {
|
|||
*out = new(intstr.IntOrString)
|
||||
**out = **in
|
||||
}
|
||||
if in.ReadIdleTimeout != nil {
|
||||
in, out := &in.ReadIdleTimeout, &out.ReadIdleTimeout
|
||||
*out = new(intstr.IntOrString)
|
||||
**out = **in
|
||||
}
|
||||
if in.PingTimeout != nil {
|
||||
in, out := &in.PingTimeout, &out.PingTimeout
|
||||
*out = new(intstr.IntOrString)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue