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

Add validations for Stabilizationwindowseconds #4983

Merged
merged 6 commits into from
Sep 20, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio
- **Pulsar Scaler**: Add support for OAuth extensions ([#4700](https://github.com/kedacore/keda/issues/4700))

### Fixes
- **General**: Add validations for stabilizationWindowSeconds ([#4976](https://github.com/kedacore/keda/issues/4976))
- **RabbitMQ Scaler**: Allow subpaths along with vhost in connection string ([#2634](https://github.com/kedacore/keda/issues/2634))
- **Selenium Grid Scaler**: Fix latest browser version use case scaling ([#4858](https://github.com/kedacore/keda/issues/4858))
- **Solace Scaler**: Fix a bug where `queueName` is not properly escaped during URL encode ([#4936](https://github.com/kedacore/keda/issues/4936))
Expand Down
20 changes: 20 additions & 0 deletions apis/keda/v1alpha1/scaledobject_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,26 @@ var _ = It("should validate the so update if it's removing the finalizer even if
}).ShouldNot(HaveOccurred())
})

var _ = It("shouldn't create so when stabilizationWindowSeconds exceeds 3600", func() {

namespaceName := "fail-so-creation"
namespace := createNamespace(namespaceName)
so := createScaledObject(soName, namespaceName, workloadName, "apps/v1", "Deployment", false, map[string]string{}, "")
so.Spec.Advanced.HorizontalPodAutoscalerConfig = &HorizontalPodAutoscalerConfig{
Behavior: &v2.HorizontalPodAutoscalerBehavior{
ScaleDown: &v2.HPAScalingRules{
StabilizationWindowSeconds: ptr.To[int32](3700),
},
},
}
err := k8sClient.Create(context.Background(), namespace)
Expect(err).ToNot(HaveOccurred())

Eventually(func() error {
return k8sClient.Create(context.Background(), so)
}).Should(HaveOccurred())
})

var _ = AfterSuite(func() {
cancel()
By("tearing down the test environment")
Expand Down
7 changes: 7 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ patchesJson6902:
name: scaledjobs.keda.sh
path: patches/scaledjob_patch.yaml

- target:
version: v1
group: apiextensions.k8s.io
kind: CustomResourceDefinition
name: scaledobjects.keda.sh
path: patches/scaledobject_patch.yaml

patchesStrategicMerge:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
Expand Down
18 changes: 18 additions & 0 deletions config/crd/patches/scaledobject_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
## needs to be patched because of an issue with stabilizationWindowSeconds maximum limit
## https://github.com/kedacore/keda/issues/4976
- op: add
path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/advanced/properties/horizontalPodAutoscalerConfig/properties/behavior/properties/scaleDown/properties/stabilizationWindowSeconds/minimum
value: 0

- op: add
path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/advanced/properties/horizontalPodAutoscalerConfig/properties/behavior/properties/scaleDown/properties/stabilizationWindowSeconds/maximum
value: 3600

- op: add
path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/advanced/properties/horizontalPodAutoscalerConfig/properties/behavior/properties/scaleUp/properties/stabilizationWindowSeconds/minimum
value: 0

- op: add
path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/advanced/properties/horizontalPodAutoscalerConfig/properties/behavior/properties/scaleUp/properties/stabilizationWindowSeconds/maximum
value: 3600