Skip to content

Commit

Permalink
Update after feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Brouwer <[email protected]>
  • Loading branch information
rickbrouwer committed Jan 17, 2025
1 parent 93e29ce commit e8c12c5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
1 change: 1 addition & 0 deletions apis/keda/v1alpha1/scaledobject_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ type Fallback struct {
FailureThreshold int32 `json:"failureThreshold"`
Replicas int32 `json:"replicas"`
// +optional
// +kubebuilder:default=static
// +kubebuilder:validation:Enum=static;useCurrentReplicasAsMinimum
Behavior string `json:"behavior,omitempty"`
}
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/keda.sh_scaledobjects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ spec:
description: Fallback is the spec for fallback options
properties:
behavior:
default: static
enum:
- static
- useCurrentReplicasAsMinimum
type: string
failureThreshold:
format: int32
Expand Down
6 changes: 0 additions & 6 deletions pkg/fallback/fallback.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,6 @@ func HasValidFallback(scaledObject *kedav1alpha1.ScaledObject) bool {

func doFallback(scaledObject *kedav1alpha1.ScaledObject, metricSpec v2.MetricSpec, metricName string, currentReplicas int32, suppressedError error) []external_metrics.ExternalMetricValue {
fallbackBehavior := scaledObject.Spec.Fallback.Behavior

// Check if behavior is empty
if fallbackBehavior == "" {
fallbackBehavior = kedav1alpha1.FallbackBehaviorStatic
}

fallbackReplicas := int64(scaledObject.Spec.Fallback.Replicas)
var replicas int64

Expand Down
6 changes: 0 additions & 6 deletions pkg/scaling/executor/scale_scaledobjects.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,6 @@ func (e *scaleExecutor) RequestScale(ctx context.Context, scaledObject *kedav1al

func (e *scaleExecutor) doFallbackScaling(ctx context.Context, scaledObject *kedav1alpha1.ScaledObject, currentScale *autoscalingv1.Scale, logger logr.Logger, currentReplicas int32) {
fallbackBehavior := scaledObject.Spec.Fallback.Behavior

// Check if behavior is empty
if fallbackBehavior == "" {
fallbackBehavior = kedav1alpha1.FallbackBehaviorStatic
}

fallbackReplicas := scaledObject.Spec.Fallback.Replicas

switch fallbackBehavior {
Expand Down

0 comments on commit e8c12c5

Please sign in to comment.