Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow envoyHpa maxReplicas to be equal to minReplicas #2329

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
shahar-h marked this conversation as resolved.
Show resolved Hide resolved
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