Skip to content

Commit

Permalink
Merge pull request #7 from joskfg/patch-1
Browse files Browse the repository at this point in the history
Autoescaler is always scaling less than expected
  • Loading branch information
mbogus committed Sep 26, 2018
2 parents 2aabae3 + 593b59d commit 287c6a1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"log"
"time"
"math"

"github.com/prometheus/client_golang/prometheus"
)
Expand Down Expand Up @@ -81,7 +82,7 @@ func (ctx *scaleContext) newSize(avg float64, cov float64) (int32, error) {
if cov < ctx.Coverage {
err = fmt.Errorf("not enough metrics to calculate new size, required at least %.2f was %.2f metrics ratio", ctx.Coverage, cov)
} else {
replicas = int32(avg / float64(ctx.Threshold))
replicas = int32(math.Ceil(avg / float64(ctx.Threshold)))
}
return replicas, err
}
2 changes: 1 addition & 1 deletion actuator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestNewSize(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if got, want := s, int32(2); got != want {
if got, want := s, int32(3); got != want {
t.Errorf("Expected %d, got: %d", want, got)
}
}
Expand Down

0 comments on commit 287c6a1

Please sign in to comment.