Skip to content

Commit c63e617

Browse files
authored
fix: ScalingModifiers admission checks the metric type correctly (#6687)
* fix: ScalingModifiers admission checks the metric type correctly Signed-off-by: Jorge Turrado <[email protected]> * fix: ScalingModifiers admission checks the metric type correctly Signed-off-by: Jorge Turrado <[email protected]> --------- Signed-off-by: Jorge Turrado <[email protected]>
1 parent 0375467 commit c63e617

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Diff for: apis/keda/v1alpha1/scaledobject_types.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ type ScalingModifiers struct {
136136
// +optional
137137
ActivationTarget string `json:"activationTarget,omitempty"`
138138
// +optional
139+
// +kubebuilder:validation:Enum=AverageValue;Value
139140
MetricType autoscalingv2.MetricTargetType `json:"metricType,omitempty"`
140141
}
141142

@@ -295,7 +296,7 @@ func CheckFallbackValid(scaledObject *ScaledObject) error {
295296
}
296297

297298
if scaledObject.IsUsingModifiers() {
298-
if scaledObject.Spec.Advanced.ScalingModifiers.MetricType != autoscalingv2.AverageValueMetricType {
299+
if scaledObject.Spec.Advanced.ScalingModifiers.MetricType == autoscalingv2.ValueMetricType {
299300
return fmt.Errorf("when using ScalingModifiers, ScaledObject.Spec.Advanced.ScalingModifiers.MetricType must be AverageValue to have fallback enabled")
300301
}
301302
} else {

Diff for: config/crd/bases/keda.sh_scaledobjects.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ spec:
214214
description: |-
215215
MetricTargetType specifies the type of metric being targeted, and should be either
216216
"Value", "AverageValue", or "Utilization"
217+
enum:
218+
- AverageValue
219+
- Value
217220
type: string
218221
target:
219222
type: string

0 commit comments

Comments
 (0)