Skip to content

Commit

Permalink
fix: hpa recommender fluctuation-threshold default value not valid
Browse files Browse the repository at this point in the history
  • Loading branch information
xinmei.mao committed Feb 28, 2024
1 parent ed43bd2 commit 61d8197
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions pkg/recommendation/recommender/hpa/recommend.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"math"
"strconv"
"time"

"github.com/montanaflynn/stats"
Expand Down Expand Up @@ -241,18 +240,13 @@ func (rr *HPARecommender) minMaxMedians(predictionTs []*common.TimeSeries) (floa

// checkFluctuation check if the time series fluctuation is reach to replicas.fluctuation-threshold
func (rr *HPARecommender) checkFluctuation(medianMin, medianMax float64) error {
fluctuationThreshold, err := strconv.ParseFloat(rr.Config["fluctuation-threshold"], 64)
if err != nil {
return err
}

if medianMin == 0 {
medianMin = 0.1 // use a small value to continue calculate
}

fluctuation := medianMax / medianMin
if fluctuation < fluctuationThreshold {
return fmt.Errorf("target cpu fluctuation %f is under replicas.fluctuation-threshold %f. ", fluctuation, fluctuationThreshold)
if fluctuation < rr.FluctuationThreshold {
return fmt.Errorf("target cpu fluctuation %f is under replicas.fluctuation-threshold %f. ", fluctuation, rr.FluctuationThreshold)
}

return nil
Expand Down

0 comments on commit 61d8197

Please sign in to comment.