From 7a378839bfc9d44c7f831df492491b411971a5f0 Mon Sep 17 00:00:00 2001 From: Dingkang Li Date: Wed, 8 May 2024 16:56:19 +0800 Subject: [PATCH] Add consistent hash table size api Signed-off-by: Dingkang Li --- api/v1alpha1/loadbalancer_types.go | 8 ++++++++ api/v1alpha1/zz_generated.deepcopy.go | 7 ++++++- .../gateway.envoyproxy.io_backendtrafficpolicies.yaml | 8 ++++++++ site/content/en/latest/api/extension_types.md | 1 + 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/api/v1alpha1/loadbalancer_types.go b/api/v1alpha1/loadbalancer_types.go index 3bd4d9c4e54..2b3ab91b828 100644 --- a/api/v1alpha1/loadbalancer_types.go +++ b/api/v1alpha1/loadbalancer_types.go @@ -55,6 +55,14 @@ const ( // load balancer policy type ConsistentHash struct { Type ConsistentHashType `json:"type"` + + // The table size for consistent hashing, must be prime number limited to 5000011. + // + // +kubebuilder:validation:Minimum=1 + // +kubebuilder:validation:Maximum=5000011 + // +kubebuilder:default=65537 + // +optional + TableSize *uint64 `json:"tableSize,omitempty"` } // ConsistentHashType defines the type of input to hash on. diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 8ebd4453c5c..7c59e4f3123 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -751,6 +751,11 @@ func (in *ConnectionLimit) DeepCopy() *ConnectionLimit { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ConsistentHash) DeepCopyInto(out *ConsistentHash) { *out = *in + if in.TableSize != nil { + in, out := &in.TableSize, &out.TableSize + *out = new(uint64) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConsistentHash. @@ -2865,7 +2870,7 @@ func (in *LoadBalancer) DeepCopyInto(out *LoadBalancer) { if in.ConsistentHash != nil { in, out := &in.ConsistentHash, &out.ConsistentHash *out = new(ConsistentHash) - **out = **in + (*in).DeepCopyInto(*out) } if in.SlowStart != nil { in, out := &in.SlowStart, &out.SlowStart diff --git a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml index eb8457a116b..b51c0ae8cdc 100644 --- a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml +++ b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml @@ -412,6 +412,14 @@ spec: ConsistentHash defines the configuration when the load balancer type is set to ConsistentHash properties: + tableSize: + default: 65537 + description: The table size for consistent hashing, must be + prime number limited to 5000011. + format: int64 + maximum: 5000011 + minimum: 1 + type: integer type: description: ConsistentHashType defines the type of input to hash on. diff --git a/site/content/en/latest/api/extension_types.md b/site/content/en/latest/api/extension_types.md index c00e9d8a915..3540a04b8ab 100644 --- a/site/content/en/latest/api/extension_types.md +++ b/site/content/en/latest/api/extension_types.md @@ -563,6 +563,7 @@ _Appears in:_ | Field | Type | Required | Description | | --- | --- | --- | --- | | `type` | _[ConsistentHashType](#consistenthashtype)_ | true | | +| `tableSize` | _integer_ | false | The table size for consistent hashing, must be prime number limited to 5000011. | #### ConsistentHashType