Skip to content

Commit 42e8320

Browse files
Merge pull request #2547 from alebedev87/OCPBUGS-61858-http-keep-alive-timeout
OCPBUGS-61858: Add HTTPKeepAliveTimeout to IngressController API
2 parents 138912d + 7301e87 commit 42e8320

File tree

7 files changed

+232
-11
lines changed

7 files changed

+232
-11
lines changed

openapi/generated_openapi/zz_generated.openapi.go

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

operator/v1/tests/ingresscontrollers.operator.openshift.io/AAA_ungated.yaml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,113 @@ tests:
563563
tuningOptions:
564564
connectTimeout: "4 s"
565565
expectedError: "IngressController.operator.openshift.io \"default\" is invalid: spec.tuningOptions.connectTimeout: Invalid value: \"4 s\": spec.tuningOptions.connectTimeout in body should match '^(0|([0-9]+(\\.[0-9]+)?(ns|us|µs|μs|ms|s|m|h))+)$'"
566+
- name: Should be able to create an IngressController with valid nominal httpKeepAlive timeout
567+
initial: |
568+
apiVersion: operator.openshift.io/v1
569+
kind: IngressController
570+
metadata:
571+
name: default
572+
namespace: openshift-ingress-operator
573+
spec:
574+
tuningOptions:
575+
httpKeepAliveTimeout: 10s
576+
expected: |
577+
apiVersion: operator.openshift.io/v1
578+
kind: IngressController
579+
metadata:
580+
name: default
581+
namespace: openshift-ingress-operator
582+
spec:
583+
httpEmptyRequestsPolicy: Respond
584+
idleConnectionTerminationPolicy: Immediate
585+
tuningOptions:
586+
httpKeepAliveTimeout: 10s
587+
- name: Should be able to create an IngressController with valid composite httpKeepAlive timeout
588+
initial: |
589+
apiVersion: operator.openshift.io/v1
590+
kind: IngressController
591+
metadata:
592+
name: default
593+
namespace: openshift-ingress-operator
594+
spec:
595+
tuningOptions:
596+
httpKeepAliveTimeout: 100s300ms
597+
expected: |
598+
apiVersion: operator.openshift.io/v1
599+
kind: IngressController
600+
metadata:
601+
name: default
602+
namespace: openshift-ingress-operator
603+
spec:
604+
httpEmptyRequestsPolicy: Respond
605+
idleConnectionTerminationPolicy: Immediate
606+
tuningOptions:
607+
httpKeepAliveTimeout: 100s300ms
608+
- name: Should be able to create an IngressController with valid fraction httpKeepAlive timeout
609+
initial: |
610+
apiVersion: operator.openshift.io/v1
611+
kind: IngressController
612+
metadata:
613+
name: default
614+
namespace: openshift-ingress-operator
615+
spec:
616+
tuningOptions:
617+
httpKeepAliveTimeout: 1.5m
618+
expected: |
619+
apiVersion: operator.openshift.io/v1
620+
kind: IngressController
621+
metadata:
622+
name: default
623+
namespace: openshift-ingress-operator
624+
spec:
625+
httpEmptyRequestsPolicy: Respond
626+
idleConnectionTerminationPolicy: Immediate
627+
tuningOptions:
628+
httpKeepAliveTimeout: 1.5m
629+
- name: Should not be able to create an IngressController with invalid unit httpKeepAlive timeout
630+
initial: |
631+
apiVersion: operator.openshift.io/v1
632+
kind: IngressController
633+
metadata:
634+
name: default
635+
namespace: openshift-ingress-operator
636+
spec:
637+
tuningOptions:
638+
httpKeepAliveTimeout: 3d
639+
expectedError: "IngressController.operator.openshift.io \"default\" is invalid: spec.tuningOptions.httpKeepAliveTimeout: Invalid value: \"string\": httpKeepAliveTimeout must be a valid duration string composed of an unsigned integer value, optionally followed by a decimal fraction and a unit suffix (ms, s, m)"
640+
- name: Should not be able to create an IngressController with invalid space httpKeepAlive timeout
641+
initial: |
642+
apiVersion: operator.openshift.io/v1
643+
kind: IngressController
644+
metadata:
645+
name: default
646+
namespace: openshift-ingress-operator
647+
spec:
648+
tuningOptions:
649+
httpKeepAliveTimeout: "4 s"
650+
expectedError: "IngressController.operator.openshift.io \"default\" is invalid: spec.tuningOptions.httpKeepAliveTimeout: Invalid value: \"string\": httpKeepAliveTimeout must be a valid duration string composed of an unsigned integer value, optionally followed by a decimal fraction and a unit suffix (ms, s, m)"
651+
- name: Should not be able to create an IngressController with httpKeepAlive timeout too big
652+
initial: |
653+
apiVersion: operator.openshift.io/v1
654+
kind: IngressController
655+
metadata:
656+
name: default
657+
namespace: openshift-ingress-operator
658+
spec:
659+
tuningOptions:
660+
httpKeepAliveTimeout: 100m
661+
expectedError: "IngressController.operator.openshift.io \"default\" is invalid: spec.tuningOptions.httpKeepAliveTimeout: Invalid value: \"string\": httpKeepAliveTimeout must be less than or equal to 15 minutes"
662+
- name: Should not be able to create an IngressController with httpKeepAlive timeout too small
663+
initial: |
664+
apiVersion: operator.openshift.io/v1
665+
kind: IngressController
666+
metadata:
667+
name: default
668+
namespace: openshift-ingress-operator
669+
spec:
670+
tuningOptions:
671+
httpKeepAliveTimeout: 0.001ms
672+
expectedError: "IngressController.operator.openshift.io \"default\" is invalid: spec.tuningOptions.httpKeepAliveTimeout: Invalid value: \"string\": httpKeepAliveTimeout must be greater than or equal to 1 millisecond"
566673
- name: Should be able to create an IngressController with valid domain
567674
initial: |
568675
apiVersion: operator.openshift.io/v1

operator/v1/types_ingress.go

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,9 @@ type IngressControllerSpec struct {
298298
// case HAProxy handles it in the old process and closes
299299
// the connection after sending the response.
300300
//
301-
// - HAProxy's `timeout http-keep-alive` duration expires
302-
// (300 seconds in OpenShift's configuration, not
303-
// configurable).
301+
// - HAProxy's `timeout http-keep-alive` duration expires.
302+
// By default this is 300 seconds, but it can be changed
303+
// using httpKeepAliveTimeout tuning option.
304304
//
305305
// - The client's keep-alive timeout expires, causing the
306306
// client to close the connection.
@@ -1884,6 +1884,36 @@ type IngressControllerTuningOptions struct {
18841884
// +optional
18851885
ConnectTimeout *metav1.Duration `json:"connectTimeout,omitempty"`
18861886

1887+
// httpKeepAliveTimeout defines the maximum allowed time to wait for
1888+
// a new HTTP request to appear on a connection from the client to the router.
1889+
//
1890+
// This field expects an unsigned duration string of a decimal number, with optional
1891+
// fraction and a unit suffix, e.g. "300ms", "1.5s" or "2m45s".
1892+
// Valid time units are "ms", "s", "m".
1893+
// The allowed range is from 1 millisecond to 15 minutes.
1894+
//
1895+
// When omitted, this means the user has no opinion and the platform is left
1896+
// to choose a reasonable default. This default is subject to change over time.
1897+
// The current default is 300s.
1898+
//
1899+
// Low values (tens of milliseconds or less) can cause clients to close and reopen connections
1900+
// for each request, leading to reduced connection sharing.
1901+
// For HTTP/2, special care should be taken with low values.
1902+
// A few seconds is a reasonable starting point to avoid holding idle connections open
1903+
// while still allowing subsequent requests to reuse the connection.
1904+
//
1905+
// High values (minutes or more) favor connection reuse but may cause idle
1906+
// connections to linger longer.
1907+
//
1908+
// +kubebuilder:validation:Type:=string
1909+
// +kubebuilder:validation:XValidation:rule="self.matches('^([0-9]+(\\\\.[0-9]+)?(ms|s|m))+$')",message="httpKeepAliveTimeout must be a valid duration string composed of an unsigned integer value, optionally followed by a decimal fraction and a unit suffix (ms, s, m)"
1910+
// +kubebuilder:validation:XValidation:rule="!self.matches('^([0-9]+(\\\\.[0-9]+)?(ms|s|m))+$') || duration(self) <= duration('15m')",message="httpKeepAliveTimeout must be less than or equal to 15 minutes"
1911+
// +kubebuilder:validation:XValidation:rule="!self.matches('^([0-9]+(\\\\.[0-9]+)?(ms|s|m))+$') || duration(self) >= duration('1ms')",message="httpKeepAliveTimeout must be greater than or equal to 1 millisecond"
1912+
// +kubebuilder:validation:MinLength=1
1913+
// +kubebuilder:validation:MaxLength=16
1914+
// +optional
1915+
HTTPKeepAliveTimeout metav1.Duration `json:"httpKeepAliveTimeout,omitempty"`
1916+
18871917
// tlsInspectDelay defines how long the router can hold data to find a
18881918
// matching route.
18891919
//

operator/v1/zz_generated.crd-manifests/0000_50_ingress_00_ingresscontrollers.crd.yaml

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,9 +1300,9 @@ spec:
13001300
case HAProxy handles it in the old process and closes
13011301
the connection after sending the response.
13021302
1303-
- HAProxy's `timeout http-keep-alive` duration expires
1304-
(300 seconds in OpenShift's configuration, not
1305-
configurable).
1303+
- HAProxy's `timeout http-keep-alive` duration expires.
1304+
By default this is 300 seconds, but it can be changed
1305+
using httpKeepAliveTimeout tuning option.
13061306
13071307
- The client's keep-alive timeout expires, causing the
13081308
client to close the connection.
@@ -2250,6 +2250,44 @@ spec:
22502250
2147483647ms (24.85 days). Both are subject to change over time.
22512251
pattern: ^(0|([0-9]+(\.[0-9]+)?(ns|us|µs|μs|ms|s|m|h))+)$
22522252
type: string
2253+
httpKeepAliveTimeout:
2254+
description: |-
2255+
httpKeepAliveTimeout defines the maximum allowed time to wait for
2256+
a new HTTP request to appear on a connection from the client to the router.
2257+
2258+
This field expects an unsigned duration string of a decimal number, with optional
2259+
fraction and a unit suffix, e.g. "300ms", "1.5s" or "2m45s".
2260+
Valid time units are "ms", "s", "m".
2261+
The allowed range is from 1 millisecond to 15 minutes.
2262+
2263+
When omitted, this means the user has no opinion and the platform is left
2264+
to choose a reasonable default. This default is subject to change over time.
2265+
The current default is 300s.
2266+
2267+
Low values (tens of milliseconds or less) can cause clients to close and reopen connections
2268+
for each request, leading to reduced connection sharing.
2269+
For HTTP/2, special care should be taken with low values.
2270+
A few seconds is a reasonable starting point to avoid holding idle connections open
2271+
while still allowing subsequent requests to reuse the connection.
2272+
2273+
High values (minutes or more) favor connection reuse but may cause idle
2274+
connections to linger longer.
2275+
maxLength: 16
2276+
minLength: 1
2277+
type: string
2278+
x-kubernetes-validations:
2279+
- message: httpKeepAliveTimeout must be a valid duration string
2280+
composed of an unsigned integer value, optionally followed
2281+
by a decimal fraction and a unit suffix (ms, s, m)
2282+
rule: self.matches('^([0-9]+(\\.[0-9]+)?(ms|s|m))+$')
2283+
- message: httpKeepAliveTimeout must be less than or equal to
2284+
15 minutes
2285+
rule: '!self.matches(''^([0-9]+(\\.[0-9]+)?(ms|s|m))+$'') ||
2286+
duration(self) <= duration(''15m'')'
2287+
- message: httpKeepAliveTimeout must be greater than or equal
2288+
to 1 millisecond
2289+
rule: '!self.matches(''^([0-9]+(\\.[0-9]+)?(ms|s|m))+$'') ||
2290+
duration(self) >= duration(''1ms'')'
22532291
maxConnections:
22542292
description: |-
22552293
maxConnections defines the maximum number of simultaneous

operator/v1/zz_generated.deepcopy.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)