Add logging to scale from zero requests

Trivial change to add logging around scale from zero events in scaling.go.
Previously scale from zero events were not logged in the same way that normal
scaling events are.  This change adds log writes to show when a scale from zero
was requested and when a function successfully moved to > 0 replicas.

Signed-off-by: Richard Gee <richard@technologee.co.uk>
This commit is contained in:
Richard Gee 2018-10-19 20:48:57 +01:00 committed by Alex Ellis
parent 70a5e343c5
commit 7df548668f

View File

@ -55,6 +55,9 @@ func MakeScalingHandler(next http.HandlerFunc, upstream http.HandlerFunc, config
minReplicas = queryResponse.MinReplicas
}
log.Printf("[Scale] function=%s 0 => %d requested", functionName, minReplicas)
scalingStartTime := time.Now()
err := config.ServiceQuery.SetReplicas(functionName, minReplicas)
if err != nil {
errStr := fmt.Errorf("unable to scale function [%s], err: %s", functionName, err)
@ -79,6 +82,8 @@ func MakeScalingHandler(next http.HandlerFunc, upstream http.HandlerFunc, config
}
if queryResponse.AvailableReplicas > 0 {
scalingDuration := time.Since(scalingStartTime)
log.Printf("[Scale] function=%s 0 => %d successful - %f seconds", functionName, queryResponse.AvailableReplicas, scalingDuration.Seconds())
break
}