Skip to content

Commit

Permalink
fix: fix waiting to reach failureThreshold before fallback
Browse files Browse the repository at this point in the history
Signed-off-by: Youssef Rabie <[email protected]>
  • Loading branch information
y-rabie committed Feb 1, 2025
1 parent d76aa17 commit 371c33b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 26 deletions.
7 changes: 0 additions & 7 deletions pkg/scaling/executor/scale_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,3 @@ func (e *scaleExecutor) setActiveCondition(ctx context.Context, logger logr.Logg
}
return e.setCondition(ctx, logger, object, status, reason, message, active)
}

func (e *scaleExecutor) setFallbackCondition(ctx context.Context, logger logr.Logger, object interface{}, status metav1.ConditionStatus, reason string, message string) error {
fallback := func(conditions kedav1alpha1.Conditions, status metav1.ConditionStatus, reason string, message string) {
conditions.SetFallbackCondition(status, reason, message)
}
return e.setCondition(ctx, logger, object, status, reason, message, fallback)
}
19 changes: 0 additions & 19 deletions pkg/scaling/executor/scale_scaledobjects.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,6 @@ func (e *scaleExecutor) RequestScale(ctx context.Context, scaledObject *kedav1al
} else {
// isActive == false
switch {
case isError && scaledObject.Spec.Fallback != nil && scaledObject.Spec.Fallback.Replicas != 0:
// there are no active triggers, but a scaler responded with an error
// AND
// there is a fallback replicas count defined

// Scale to the fallback replicas count
e.doFallbackScaling(ctx, scaledObject, currentScale, logger, currentReplicas)
case isError && scaledObject.Spec.Fallback == nil:
// there are no active triggers, but a scaler responded with an error
// AND
Expand Down Expand Up @@ -230,18 +223,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) {
_, err := e.updateScaleOnScaleTarget(ctx, scaledObject, currentScale, scaledObject.Spec.Fallback.Replicas)
if err == nil {
logger.Info("Successfully set ScaleTarget replicas count to ScaledObject fallback.replicas",
"Original Replicas Count", currentReplicas,
"New Replicas Count", scaledObject.Spec.Fallback.Replicas)
}
if e := e.setFallbackCondition(ctx, logger, scaledObject, metav1.ConditionTrue, "FallbackExists", "At least one trigger is falling back on this scaled object"); e != nil {
logger.Error(e, "Error setting fallback condition")
}
}

// An object will be scaled down to 0 only if it's passed its cooldown period
// or if LastActiveTime is nil
func (e *scaleExecutor) scaleToZeroOrIdle(ctx context.Context, logger logr.Logger, scaledObject *kedav1alpha1.ScaledObject, scale *autoscalingv1.Scale) {
Expand Down

0 comments on commit 371c33b

Please sign in to comment.