Skip to content

Commit

Permalink
fix bug in calculate cpuUtilization
Browse files Browse the repository at this point in the history
  • Loading branch information
qmhu committed Feb 23, 2022
1 parent ca5b183 commit 19c05aa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/recommend/advisor/ehpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ func (a *EHPAAdvisor) Advise(proposed *types.ProposedRecommendation) error {
targetCpuUtilization := int32(50) // todo: configurable
maxReplicasFactor := 1.2 // todo: configurable

maxCpuUtilization := int32(int64(maxCpuUsage) * 1000 * 100 / requestTotal)
maxCpuUtilization := int32(int64(maxCpuUsage) * 1000 * 100 * int64(len(a.Pods)) / requestTotal)
proposedMaxRatio := float64(maxCpuUtilization) / float64(targetCpuUtilization)
maxReplicasProposed := int32(math.Ceil(proposedMaxRatio * float64(a.ReadyPodNumber) * maxReplicasFactor))

minCpuUtilization := int32(int64(minCpuUsage) * 1000 * 100 / requestTotal)
minCpuUtilization := int32(int64(minCpuUsage) * 1000 * 100 * int64(len(a.Pods)) / requestTotal)
proposedMinRatio := float64(minCpuUtilization) / float64(targetCpuUtilization)
minReplicasProposed := int32(math.Ceil(proposedMinRatio * float64(a.ReadyPodNumber)))

Expand Down

0 comments on commit 19c05aa

Please sign in to comment.