Skip to content

Commit

Permalink
fix: prevent violent scale-up and scale-down by only scaling by 1 eac…
Browse files Browse the repository at this point in the history
…h time
  • Loading branch information
alexec committed Jun 4, 2021
1 parent ca363fe commit 60eab31
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions api/v1alpha1/step_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@ func (in *Step) GetTargetReplicas(currentReplicas int, scalingDelay, peekDelay t
if currentReplicas <= 0 && targetReplicas == 0 && time.Since(lastScaledAt) > peekDelay {
return 1
}

return targetReplicas
// prevent violent scale-up and scale-down by only scaling by 1 each time
if targetReplicas > currentReplicas {
return currentReplicas + 1
} else if targetReplicas < currentReplicas {
return currentReplicas - 1
} else {
return targetReplicas
}
}

func RequeueAfter(currentReplicas, targetReplicas int, scalingDelay time.Duration) time.Duration {
Expand Down

0 comments on commit 60eab31

Please sign in to comment.