Skip to content

Commit d15f442

Browse files
Add support for initialCooldownPeriod On httpScaledObjects (#1212)
* Add support for initialCooldownPeriod On httpScaledObjects Signed-off-by: Shay Rybak <shay.rybak@similarweb.com> * update changelog Signed-off-by: Shay Rybak <shay.rybak@similarweb.com> * make manifests Signed-off-by: Shay Rybak <shay.rybak@similarweb.com> * Update InititalCooldownPeriod to *int32 Signed-off-by: Shay Rybak <shay.rybak@similarweb.com> * nil ptr check for setting initialCooldownPeriod Signed-off-by: Jan Wozniak <wozniak.jan@gmail.com> * make generate manifests Signed-off-by: Jan Wozniak <wozniak.jan@gmail.com> --------- Signed-off-by: Shay Rybak <shay.rybak@similarweb.com> Signed-off-by: Jan Wozniak <wozniak.jan@gmail.com> Co-authored-by: Jan Wozniak <wozniak.jan@gmail.com>
1 parent 8a6ae99 commit d15f442

File tree

6 files changed

+20
-1
lines changed

6 files changed

+20
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ This changelog keeps track of work items that have been completed and are ready
2828

2929
- **General**: TODO ([#TODO](https://github.com/kedacore/http-add-on/issues/TODO))
3030
- **General**: Fix kubectl active printcolumn ([#1211](https://github.com/kedacore/http-add-on/issues/1211))
31+
- **General**: Support InitialCooldownPeriod for HTTPScaledObject [#1213](https://github.com/kedacore/http-add-on/issues/1213)
3132

3233
### Improvements
3334

config/crd/bases/http.keda.sh_httpscaledobjects.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ spec:
6969
items:
7070
type: string
7171
type: array
72+
initialCooldownPeriod:
73+
description: (optional) Initial period before scaling
74+
format: int32
75+
type: integer
7276
pathPrefixes:
7377
description: |-
7478
The paths to route. All requests which the Request Target matches any

operator/apis/http/v1alpha1/httpscaledobject_types.go

+3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ type HTTPScaledObjectSpec struct {
102102
// (optional) Cooldown period value
103103
// +optional
104104
CooldownPeriod *int32 `json:"scaledownPeriod,omitempty" description:"Cooldown period (seconds) for resources to scale down (Default 300)"`
105+
// (optional) Initial period before scaling
106+
// +optional
107+
InitialCooldownPeriod *int32 `json:"initialCooldownPeriod,omitempty" description:"Initial period (seconds) before scaling (Default 0)"`
105108
// (optional) Configuration for the metric used for scaling
106109
// +optional
107110
ScalingMetric *ScalingMetricSpec `json:"scalingMetric,omitempty" description:"Configuration for the metric used for scaling. If empty 'concurrency' will be used"`

operator/apis/http/v1alpha1/zz_generated.deepcopy.go

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

operator/controllers/http/scaled_object.go

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func (r *HTTPScaledObjectReconciler) createOrUpdateScaledObject(
4444
minReplicaCount,
4545
maxReplicaCount,
4646
httpso.Spec.CooldownPeriod,
47+
httpso.Spec.InitialCooldownPeriod,
4748
)
4849

4950
// Set HTTPScaledObject instance as the owner and controller

pkg/k8s/scaledobject.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ func NewScaledObject(
2727
minReplicas *int32,
2828
maxReplicas *int32,
2929
cooldownPeriod *int32,
30+
initialCooldownPeriod *int32,
3031
) *kedav1alpha1.ScaledObject {
31-
return &kedav1alpha1.ScaledObject{
32+
so := &kedav1alpha1.ScaledObject{
3233
TypeMeta: metav1.TypeMeta{
3334
APIVersion: kedav1alpha1.SchemeGroupVersion.Identifier(),
3435
Kind: ObjectKind(&kedav1alpha1.ScaledObject{}),
@@ -63,4 +64,8 @@ func NewScaledObject(
6364
},
6465
},
6566
}
67+
if initialCooldownPeriod != nil {
68+
so.Spec.InitialCooldownPeriod = *initialCooldownPeriod
69+
}
70+
return so
6671
}

0 commit comments

Comments
 (0)