Handle edge cases in seat demand stats

Signed-off-by: Mike Spreitzer <mspreitz@us.ibm.com>

Kubernetes-commit: b0e249f657a18c1435ace391fa752711dafce732
This commit is contained in:
Mike Spreitzer 2023-08-21 15:26:38 -04:00 committed by Kubernetes Publisher
parent 08f8ff0d3f
commit 7c7ff34a5a
1 changed files with 7 additions and 1 deletions

View File

@ -263,9 +263,15 @@ type seatDemandStats struct {
}
func (stats *seatDemandStats) update(obs fq.IntegratorResults) {
stats.highWatermark = obs.Max
if obs.Duration <= 0 {
return
}
if math.IsNaN(obs.Deviation) {
obs.Deviation = 0
}
stats.avg = obs.Average
stats.stdDev = obs.Deviation
stats.highWatermark = obs.Max
envelope := obs.Average + obs.Deviation
stats.smoothed = math.Max(envelope, seatDemandSmoothingCoefficient*stats.smoothed+(1-seatDemandSmoothingCoefficient)*envelope)
}