Skip to content

Commit

Permalink
fix: allow envoyHpa maxReplicas to be equal to minReplicas
Browse files Browse the repository at this point in the history
Signed-off-by: Shahar Harari <[email protected]>
  • Loading branch information
shahar-h committed Dec 20, 2023
1 parent d13c329 commit 8200ff0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha1/envoyproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 18 additions & 1 deletion test/cel-validation/envoyproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 8200ff0

Please sign in to comment.