Autoscaling: Percentage runners busy - remove magic number used for round up (#235)

* remove magic number for autoscaling

Co-authored-by: Zachary Benamram <zacharybenamram@blend.com>
This commit is contained in:
ZacharyBenamram 2020-12-14 21:38:01 -08:00 committed by GitHub
parent 466b30728d
commit 48923fec56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"math"
"strconv" "strconv"
"strings" "strings"
@ -218,7 +219,7 @@ func (r *HorizontalRunnerAutoscalerReconciler) calculateReplicasByPercentageRunn
var desiredReplicas int var desiredReplicas int
fractionBusy := float64(numRunnersBusy) / float64(numRunners) fractionBusy := float64(numRunnersBusy) / float64(numRunners)
if fractionBusy >= scaleUpThreshold { if fractionBusy >= scaleUpThreshold {
scaleUpReplicas := int(float64(numRunners)*scaleUpFactor + 0.5) scaleUpReplicas := int(math.Ceil(float64(numRunners) * scaleUpFactor))
if scaleUpReplicas > maxReplicas { if scaleUpReplicas > maxReplicas {
desiredReplicas = maxReplicas desiredReplicas = maxReplicas
} else { } else {