Skip to content

Commit

Permalink
Update scale_scaledobjects.go
Browse files Browse the repository at this point in the history
Signed-off-by: rickbrouwer <[email protected]>
  • Loading branch information
rickbrouwer authored Jan 15, 2025
1 parent bdf609f commit cbaf778
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/scaling/executor/scale_scaledobjects.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,16 @@ 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) {
targetReplicas := scaledObject.Spec.Fallback.Replicas
fallbackBehavior := scaledObject.Spec.Fallback.Behavior

// Check if we should use current replicas as minimum
if scaledObject.Spec.Fallback.UseCurrentReplicasAsMinimum != nil && *scaledObject.Spec.Fallback.UseCurrentReplicasAsMinimum && currentReplicas > targetReplicas {
// Check behavior 'UseCurrentReplicasAsMin'
if fallbackBehavior == kedav1alpha1.FallbackBehaviorUseCurrentReplicasAsMin && currentReplicas > targetReplicas {
targetReplicas = currentReplicas
}

_, err := e.updateScaleOnScaleTarget(ctx, scaledObject, currentScale, targetReplicas)
if err == nil {
logger.Info("Successfully set ScaleTarget replicas count to calculated fallback replicas", "Original Replicas Count", currentReplicas, "New Replicas Count", targetReplicas)
logger.Info("Successfully set ScaleTarget replicas count to calculated fallback replicas", "Original Replicas Count", currentReplicas, "New Replicas Count", targetReplicas, "Behavior", fallbackBehavior)
}
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")
Expand Down

0 comments on commit cbaf778

Please sign in to comment.