From 8200ff07e3d2bdd072968b9873b1757a12d756d2 Mon Sep 17 00:00:00 2001 From: Shahar Harari Date: Wed, 20 Dec 2023 15:00:17 +0200 Subject: [PATCH] fix: allow envoyHpa maxReplicas to be equal to minReplicas Signed-off-by: Shahar Harari --- api/v1alpha1/envoyproxy_types.go | 2 +- .../gateway.envoyproxy.io_envoyproxies.yaml | 4 ++-- test/cel-validation/envoyproxy_test.go | 19 ++++++++++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/api/v1alpha1/envoyproxy_types.go b/api/v1alpha1/envoyproxy_types.go index acf34417c76..e11da79d850 100644 --- a/api/v1alpha1/envoyproxy_types.go +++ b/api/v1alpha1/envoyproxy_types.go @@ -134,7 +134,7 @@ type EnvoyProxyKubernetesProvider struct { // +optional // +kubebuilder:validation:XValidation:message="minReplicas must be greater than 0",rule="!has(self.minReplicas) || self.minReplicas > 0" // +kubebuilder:validation:XValidation:message="maxReplicas must be greater than 0",rule="!has(self.maxReplicas) || self.maxReplicas > 0" - // +kubebuilder:validation:XValidation:message="maxReplicas cannot be less than or equal to minReplicas",rule="!has(self.minReplicas) || self.maxReplicas > self.minReplicas" + // +kubebuilder:validation:XValidation:message="maxReplicas cannot be less than minReplicas",rule="!has(self.minReplicas) || self.maxReplicas >= self.minReplicas" EnvoyHpa *KubernetesHorizontalPodAutoscalerSpec `json:"envoyHpa,omitempty"` } diff --git a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyproxies.yaml b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyproxies.yaml index ed653daf7b2..11c48953e58 100644 --- a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyproxies.yaml +++ b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_envoyproxies.yaml @@ -6272,8 +6272,8 @@ spec: rule: '!has(self.minReplicas) || self.minReplicas > 0' - message: maxReplicas must be greater than 0 rule: '!has(self.maxReplicas) || self.maxReplicas > 0' - - message: maxReplicas cannot be less than or equal to minReplicas - rule: '!has(self.minReplicas) || self.maxReplicas > self.minReplicas' + - message: maxReplicas cannot be less than minReplicas + rule: '!has(self.minReplicas) || self.maxReplicas >= self.minReplicas' envoyService: description: EnvoyService defines the desired state of the Envoy service resource. If unspecified, default settings diff --git a/test/cel-validation/envoyproxy_test.go b/test/cel-validation/envoyproxy_test.go index 40347665ea8..9f029534b12 100644 --- a/test/cel-validation/envoyproxy_test.go +++ b/test/cel-validation/envoyproxy_test.go @@ -481,7 +481,24 @@ func TestEnvoyProxyProvider(t *testing.T) { }, } }, - wantErrors: []string{"maxReplicas cannot be less than or equal to minReplicas"}, + wantErrors: []string{"maxReplicas cannot be less than minReplicas"}, + }, + { + desc: "ProxyHpa-maxReplicas-equals-to-minReplicas", + mutate: func(envoy *egv1a1.EnvoyProxy) { + envoy.Spec = egv1a1.EnvoyProxySpec{ + Provider: &egv1a1.EnvoyProxyProvider{ + Type: egv1a1.ProviderTypeKubernetes, + Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{ + EnvoyHpa: &egv1a1.KubernetesHorizontalPodAutoscalerSpec{ + MinReplicas: ptr.To[int32](2), + MaxReplicas: ptr.To[int32](2), + }, + }, + }, + } + }, + wantErrors: []string{}, }, { desc: "ProxyHpa-valid",