Set default max scale to 5 replicas and a 10% increment

Sets a new default maximum scale limit of 5 replicas out of
the box for CE users, CE meaning "Community" rather than
"Commercial".

The increment factor of 10 vs 25 should not make a difference
to genuine community and hobbyist users.

Tested and verified with unit tests and hey with a CE cluster
where the maximum limit was reached over several minutes,
finally going back to 1 replica.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (OpenFaaS Ltd)
2023-01-17 21:01:36 +00:00
parent 21a8f0cec1
commit 8e1c34e222
6 changed files with 64 additions and 71 deletions

View File

@ -7,7 +7,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net"
"net/http"
@ -89,7 +89,7 @@ func (s ExternalServiceQuery) GetReplicas(serviceName, serviceNamespace string)
var bytesOut []byte
if res.Body != nil {
bytesOut, _ = ioutil.ReadAll(res.Body)
bytesOut, _ = io.ReadAll(res.Body)
defer res.Body.Close()
}
@ -111,20 +111,17 @@ func (s ExternalServiceQuery) GetReplicas(serviceName, serviceNamespace string)
scalingFactor := uint64(scaling.DefaultScalingFactor)
availableReplicas := function.AvailableReplicas
targetLoad := uint64(scaling.DefaultTargetLoad)
if function.Labels != nil {
labels := *function.Labels
minReplicas = extractLabelValue(labels[scaling.MinScaleLabel], minReplicas)
maxReplicas = extractLabelValue(labels[scaling.MaxScaleLabel], maxReplicas)
extractedScalingFactor := extractLabelValue(labels[scaling.ScalingFactorLabel], scalingFactor)
targetLoad = extractLabelValue(labels[scaling.TargetLoadLabel], targetLoad)
if extractedScalingFactor >= 0 && extractedScalingFactor <= 100 {
if extractedScalingFactor > 0 && extractedScalingFactor <= 100 {
scalingFactor = extractedScalingFactor
} else {
log.Printf("Bad Scaling Factor: %d, is not in range of [0 - 100]. Will fallback to %d", extractedScalingFactor, scalingFactor)
return scaling.ServiceQueryResponse{}, fmt.Errorf("bad scaling factor: %d, is not in range of [0 - 100]", extractedScalingFactor)
}
}
@ -135,7 +132,6 @@ func (s ExternalServiceQuery) GetReplicas(serviceName, serviceNamespace string)
ScalingFactor: scalingFactor,
AvailableReplicas: availableReplicas,
Annotations: function.Annotations,
TargetLoad: targetLoad,
}, err
}