Skip to content

Commit

Permalink
Update fallback.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 8082c31 commit bdf609f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pkg/fallback/fallback.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ func HasValidFallback(scaledObject *kedav1alpha1.ScaledObject) bool {

func doFallback(scaledObject *kedav1alpha1.ScaledObject, metricSpec v2.MetricSpec, metricName string, currentReplicas int32, suppressedError error) []external_metrics.ExternalMetricValue {
replicas := int64(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 {
// Check behavior 'UseCurrentReplicasAsMin'
if fallbackBehavior == kedav1alpha1.FallbackBehaviorUseCurrentReplicasAsMin {
currentReplicasCount := int64(currentReplicas)
if currentReplicasCount > replicas {
replicas = currentReplicasCount
Expand All @@ -137,11 +137,13 @@ func doFallback(scaledObject *kedav1alpha1.ScaledObject, metricSpec v2.MetricSpe
}
fallbackMetrics := []external_metrics.ExternalMetricValue{metric}

log.Info("Suppressing error, using fallback metrics",
"scaledObject.Namespace", scaledObject.Namespace,
"scaledObject.Name", scaledObject.Name,
"suppressedError", suppressedError,
"fallback.replicas", replicas)
log.Info("Suppressing error, using fallback metrics",
"scaledObject.Namespace", scaledObject.Namespace,
"scaledObject.Name", scaledObject.Name,
"suppressedError", suppressedError,
"fallback.behavior", fallbackBehavior,
"fallback.replicas", replicas,
"workload.currentReplicas", currentReplicas)
return fallbackMetrics
}

Expand Down

0 comments on commit bdf609f

Please sign in to comment.