Skip to content

Commit

Permalink
fix convertQuanToPercent func
Browse files Browse the repository at this point in the history
Signed-off-by: Tian Qiu <329508111@qq.com>
  • Loading branch information
autumn0207 committed Jul 2, 2022
1 parent 8826496 commit b0bca98
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/scheduler/plugins/rescheduling/node_utilization_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ limitations under the License.
package rescheduling

import (
"sort"

v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/klog"
v1qos "k8s.io/kubernetes/pkg/apis/core/v1/helper/qos"
"sort"
"volcano.sh/volcano/pkg/scheduler/api"
)

Expand Down Expand Up @@ -207,9 +208,9 @@ func convertPercentToQuan(rName v1.ResourceName, percent float64, nodeCapacity v
func convertQuanToPercent(rName v1.ResourceName, amount *resource.Quantity, nodeCapacity v1.ResourceList) float64 {
var percent float64
if rName == v1.ResourceCPU {
percent = amount.AsApproximateFloat64() / nodeCapacity.Cpu().AsApproximateFloat64()
percent = amount.AsApproximateFloat64() * 100 / nodeCapacity.Cpu().AsApproximateFloat64()
} else if rName == v1.ResourceMemory {
percent = amount.AsApproximateFloat64() / nodeCapacity.Memory().AsApproximateFloat64()
percent = amount.AsApproximateFloat64() * 100 / nodeCapacity.Memory().AsApproximateFloat64()
}
return percent
}

0 comments on commit b0bca98

Please sign in to comment.