From 48923fec562126e2ffe575c9d7694d18c0a56f3d Mon Sep 17 00:00:00 2001 From: ZacharyBenamram Date: Mon, 14 Dec 2020 21:38:01 -0800 Subject: [PATCH] Autoscaling: Percentage runners busy - remove magic number used for round up (#235) * remove magic number for autoscaling Co-authored-by: Zachary Benamram --- controllers/autoscaling.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/autoscaling.go b/controllers/autoscaling.go index da351692..ef82aab0 100644 --- a/controllers/autoscaling.go +++ b/controllers/autoscaling.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "math" "strconv" "strings" @@ -218,7 +219,7 @@ func (r *HorizontalRunnerAutoscalerReconciler) calculateReplicasByPercentageRunn var desiredReplicas int fractionBusy := float64(numRunnersBusy) / float64(numRunners) if fractionBusy >= scaleUpThreshold { - scaleUpReplicas := int(float64(numRunners)*scaleUpFactor + 0.5) + scaleUpReplicas := int(math.Ceil(float64(numRunners) * scaleUpFactor)) if scaleUpReplicas > maxReplicas { desiredReplicas = maxReplicas } else {