Skip to content

Commit

Permalink
fix: 🐛 memory unused rate (#2335)
Browse files Browse the repository at this point in the history
  • Loading branch information
bugaolengdeyuxiaoer authored Oct 12, 2021
1 parent 0c170da commit d42b398
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,8 @@ func (t *Table) GetScaleValue(a, b float64, resourceType TableType) string {
}
return fmt.Sprintf("%.1f%s/%.1f%s", a, level[i], b, level[i])
case Cpu:
for a >= 1000 && b >= 1000 && i < 4 {
a /= 1000
b /= 1000
}
a /= 1000
b /= 1000
return fmt.Sprintf("%.3f/%.3f", a, b)
default:
for ; a >= 1000 && b >= 1000 && i < 4; i++ {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ func TestTable_GetUnusedRate(t1 *testing.T) {
name: "text",
fields: fields{},
args: args{
a: 0.2,
b: 1.2,
a: 200,
b: 1200,
resourceType: Cpu,
},
want: DistributionValue{"0.200/1.200", "16.7"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ func (mt *MemInfoTable) GetRowItems(nodes []data.Object, tableType table.TableTy
used = metricsData.Used
}
usage = mt.GetUsageValue(used, float64(requestQty.Value()), table.Memory)
unused := math.Max(float64(memRequest)-resp[key].Used*1000, 0.0)
dr = mt.GetUnusedRate(unused, float64(memRequest), table.Cpu)
unused := math.Max(float64(memRequest)-resp[key].Used, 0.0)
dr = mt.GetUnusedRate(unused, float64(memRequest), table.Memory)
role := c.StringSlice("metadata", "fields")[2]
ip := c.StringSlice("metadata", "fields")[5]
if role == "<none>" {
Expand Down

0 comments on commit d42b398

Please sign in to comment.