Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openfaas-faas
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Team Jaz CS 598 CCC Final Project
openfaas-faas
Commits
3bdb194e
Commit
3bdb194e
authored
6 years ago
by
Gede Wahyu
Committed by
Alex Ellis
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Round up value of newReplicas
Signed-off-by:
Gede Wahyu
<
tokekbesi@gmail.com
>
parent
19162915
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gateway/handlers/alerthandler.go
+2
-1
2 additions, 1 deletion
gateway/handlers/alerthandler.go
gateway/handlers/alerthandler_test.go
+11
-0
11 additions, 0 deletions
gateway/handlers/alerthandler_test.go
with
13 additions
and
1 deletion
gateway/handlers/alerthandler.go
+
2
−
1
View file @
3bdb194e
...
...
@@ -8,6 +8,7 @@ import (
"fmt"
"io/ioutil"
"log"
"math"
"net/http"
"github.com/openfaas/faas/gateway/requests"
...
...
@@ -97,7 +98,7 @@ func scaleService(alert requests.PrometheusInnerAlert, service scaling.ServiceQu
// CalculateReplicas decides what replica count to set depending on current/desired amount
func
CalculateReplicas
(
status
string
,
currentReplicas
uint64
,
maxReplicas
uint64
,
minReplicas
uint64
,
scalingFactor
uint64
)
uint64
{
newReplicas
:=
currentReplicas
step
:=
uint64
((
float64
(
maxReplicas
)
/
100
)
*
float64
(
scalingFactor
))
step
:=
uint64
(
math
.
Ceil
(
float64
(
maxReplicas
)
/
100
*
float64
(
scalingFactor
))
)
if
status
==
"firing"
&&
step
>
0
{
if
currentReplicas
+
step
>
maxReplicas
{
...
...
This diff is collapsed.
Click to expand it.
gateway/handlers/alerthandler_test.go
+
11
−
0
View file @
3bdb194e
...
...
@@ -110,3 +110,14 @@ func TestScaledUpFrom1(t *testing.T) {
t
.
Fail
()
}
}
func
TestScaledUpWithSmallParam
(
t
*
testing
.
T
)
{
currentReplicas
:=
uint64
(
1
)
maxReplicas
:=
uint64
(
4
)
scalingFactor
:=
uint64
(
1
)
newReplicas
:=
CalculateReplicas
(
"firing"
,
currentReplicas
,
maxReplicas
,
scaling
.
DefaultMinReplicas
,
scalingFactor
)
if
newReplicas
==
currentReplicas
{
t
.
Log
(
"Expected newReplicas > currentReplica"
)
t
.
Fail
()
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment