From 0307de73678cd5d563976df99c9536a165cb70c0 Mon Sep 17 00:00:00 2001 From: huabing zhao Date: Fri, 19 Apr 2024 16:02:08 -0700 Subject: [PATCH] api for http2 settings Signed-off-by: huabing zhao --- api/v1alpha1/clienttrafficpolicy_types.go | 8 ++--- api/v1alpha1/connection_types.go | 4 +-- api/v1alpha1/shared_types.go | 5 ++++ api/v1alpha1/zz_generated.deepcopy.go | 29 +++++++++++++++---- ...y.envoyproxy.io_clienttrafficpolicies.yaml | 26 ++++++++++++----- site/content/en/latest/api/extension_types.md | 18 ++++++++++-- 6 files changed, 64 insertions(+), 26 deletions(-) diff --git a/api/v1alpha1/clienttrafficpolicy_types.go b/api/v1alpha1/clienttrafficpolicy_types.go index a3d79f28d9d..d26d0315d96 100644 --- a/api/v1alpha1/clienttrafficpolicy_types.go +++ b/api/v1alpha1/clienttrafficpolicy_types.go @@ -208,17 +208,13 @@ type HTTP10Settings struct { type HTTP2Settings struct { // InitialStreamWindowSize sets the initial window size for HTTP/2 streams. // If not set, the default value is 64 KiB(64*1024). - // +kubebuilder:validation:Minimum=65535 - // +kubebuilder:validation:Maximum=2147483647 // +optional - InitialStreamWindowSize *uint32 `json:"initialStreamWindowSize,omitempty"` + InitialStreamWindowSize *Size `json:"initialStreamWindowSize,omitempty"` // InitialConnectionWindowSize sets the initial window size for HTTP/2 connections. // If not set, the default value is 1 MiB(1024*1024). - // +kubebuilder:validation:Minimum=65535 - // +kubebuilder:validation:Maximum=2147483647 // +optional - InitialConnectionWindowSize *uint32 `json:"initialConnectionWindowSize,omitempty"` + InitialConnectionWindowSize *Size `json:"initialConnectionWindowSize,omitempty"` } const ( diff --git a/api/v1alpha1/connection_types.go b/api/v1alpha1/connection_types.go index 999cfcc4144..e099d5517c6 100644 --- a/api/v1alpha1/connection_types.go +++ b/api/v1alpha1/connection_types.go @@ -6,7 +6,6 @@ package v1alpha1 import ( - "k8s.io/apimachinery/pkg/api/resource" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" ) @@ -21,9 +20,8 @@ type Connection struct { // Note that when the suffix is not provided, the value is interpreted as bytes. // Default: 32768 bytes. // - // +kubebuilder:validation:XValidation:rule="type(self) == string ? self.matches(r\"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$\") : type(self) == int",message="bufferLimit must be of the format \"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$\"" // +optional - BufferLimit *resource.Quantity `json:"bufferLimit,omitempty"` + BufferLimit *Size `json:"bufferLimit,omitempty"` } type ConnectionLimit struct { diff --git a/api/v1alpha1/shared_types.go b/api/v1alpha1/shared_types.go index cce1eaccd79..bac8ee5c811 100644 --- a/api/v1alpha1/shared_types.go +++ b/api/v1alpha1/shared_types.go @@ -10,6 +10,7 @@ import ( autoscalingv2 "k8s.io/api/autoscaling/v2" corev1 "k8s.io/api/core/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + "k8s.io/apimachinery/pkg/api/resource" gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" ) @@ -424,3 +425,7 @@ type BackendRef struct { // Only service Kind is supported for now. gwapiv1.BackendObjectReference `json:",inline"` } + +// Size is a wrapper around resource.Quantity to provide a more descriptive name and validation. +// +kubebuilder:validation:XValidation:rule="type(self) == string ? self.matches(r\"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$\") : type(self) == int",message="bufferLimit must be of the format \"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$\"" +type Size resource.Quantity diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 4ecf2826c7b..cc944ffdece 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -666,8 +666,8 @@ func (in *Connection) DeepCopyInto(out *Connection) { } if in.BufferLimit != nil { in, out := &in.BufferLimit, &out.BufferLimit - x := (*in).DeepCopy() - *out = &x + *out = new(Size) + (*in).DeepCopyInto(*out) } } @@ -2019,13 +2019,13 @@ func (in *HTTP2Settings) DeepCopyInto(out *HTTP2Settings) { *out = *in if in.InitialStreamWindowSize != nil { in, out := &in.InitialStreamWindowSize, &out.InitialStreamWindowSize - *out = new(uint32) - **out = **in + *out = new(Size) + (*in).DeepCopyInto(*out) } if in.InitialConnectionWindowSize != nil { in, out := &in.InitialConnectionWindowSize, &out.InitialConnectionWindowSize - *out = new(uint32) - **out = **in + *out = new(Size) + (*in).DeepCopyInto(*out) } } @@ -3873,6 +3873,23 @@ func (in *ShutdownConfig) DeepCopy() *ShutdownConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Size) DeepCopyInto(out *Size) { + *out = *in + out.i = in.i + in.d.DeepCopyInto(&out.d) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Size. +func (in *Size) DeepCopy() *Size { + if in == nil { + return nil + } + out := new(Size) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SlowStart) DeepCopyInto(out *SlowStart) { *out = *in diff --git a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_clienttrafficpolicies.yaml b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_clienttrafficpolicies.yaml index 75040eaf2db..672c286bb06 100644 --- a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_clienttrafficpolicies.yaml +++ b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_clienttrafficpolicies.yaml @@ -190,21 +190,31 @@ spec: description: HTTP2 provides HTTP/2 configuration on the listener. properties: initialConnectionWindowSize: + anyOf: + - type: integer + - type: string description: |- InitialConnectionWindowSize sets the initial window size for HTTP/2 connections. If not set, the default value is 1 MiB(1024*1024). - format: int32 - maximum: 2147483647 - minimum: 65535 - type: integer + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + x-kubernetes-validations: + - message: bufferLimit must be of the format "^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$" + rule: 'type(self) == string ? self.matches(r"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$") + : type(self) == int' initialStreamWindowSize: + anyOf: + - type: integer + - type: string description: |- InitialStreamWindowSize sets the initial window size for HTTP/2 streams. If not set, the default value is 64 KiB(64*1024). - format: int32 - maximum: 2147483647 - minimum: 65535 - type: integer + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + x-kubernetes-validations: + - message: bufferLimit must be of the format "^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$" + rule: 'type(self) == string ? self.matches(r"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$") + : type(self) == int' type: object http3: description: HTTP3 provides HTTP/3 configuration on the listener. diff --git a/site/content/en/latest/api/extension_types.md b/site/content/en/latest/api/extension_types.md index ff9e522b0a3..25e7a7dba1d 100644 --- a/site/content/en/latest/api/extension_types.md +++ b/site/content/en/latest/api/extension_types.md @@ -489,7 +489,7 @@ _Appears in:_ | Field | Type | Required | Description | | --- | --- | --- | --- | | `connectionLimit` | _[ConnectionLimit](#connectionlimit)_ | false | ConnectionLimit defines limits related to connections | -| `bufferLimit` | _[Quantity](#quantity)_ | false | BufferLimit provides configuration for the maximum buffer size in bytes for each incoming connection.
For example, 20Mi, 1Gi, 256Ki etc.
Note that when the suffix is not provided, the value is interpreted as bytes.
Default: 32768 bytes. | +| `bufferLimit` | _[Size](#size)_ | false | BufferLimit provides configuration for the maximum buffer size in bytes for each incoming connection.
For example, 20Mi, 1Gi, 256Ki etc.
Note that when the suffix is not provided, the value is interpreted as bytes.
Default: 32768 bytes. | #### ConnectionLimit @@ -1494,8 +1494,8 @@ _Appears in:_ | Field | Type | Required | Description | | --- | --- | --- | --- | -| `initialStreamWindowSize` | _integer_ | false | InitialStreamWindowSize sets the initial window size for HTTP/2 streams.
If not set, the default value is 64 KiB(64*1024). | -| `initialConnectionWindowSize` | _integer_ | false | InitialConnectionWindowSize sets the initial window size for HTTP/2 connections.
If not set, the default value is 1 MiB(1024*1024). | +| `initialStreamWindowSize` | _[Size](#size)_ | false | InitialStreamWindowSize sets the initial window size for HTTP/2 streams.
If not set, the default value is 64 KiB(64*1024). | +| `initialConnectionWindowSize` | _[Size](#size)_ | false | InitialConnectionWindowSize sets the initial window size for HTTP/2 connections.
If not set, the default value is 1 MiB(1024*1024). | #### HTTP3Settings @@ -2922,6 +2922,18 @@ _Appears in:_ | `minDrainDuration` | _[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.26/#duration-v1-meta)_ | false | MinDrainDuration defines the minimum drain duration allowing time for endpoint deprogramming to complete.
If unspecified, defaults to 5 seconds. | +#### Size + +_Underlying type:_ _Quantity_ + +Size is a wrapper around resource.Quantity to provide a more descriptive name and validation. + +_Appears in:_ +- [Connection](#connection) +- [HTTP2Settings](#http2settings) + + + #### SlowStart