Skip to content

Commit

Permalink
fix: 🐛 divide zoro if node does not has request (#3185)
Browse files Browse the repository at this point in the history
* fix: 🐛 divide zoro if node does not has request

* refactor: 💡 metrics data
  • Loading branch information
bugaolengdeyuxiaoer authored Nov 26, 2021
1 parent ca1041c commit 94449aa
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions conf/cmp/i18n/cp/scenarios/cmp-dashboard-nodes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ zh:
Low:
Middle:
High:
None:

en:
role: Role
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,15 @@ func (t *Table) GetDistributionValue(req, total float64, resourceType TableType)
}

func (t *Table) GetDistributionRate(allocate, request float64, resourceType TableType) DistributionRate {
if request == 0 {
return DistributionRate{RenderType: "text", Value: t.SDK.I18n("None")}
}
rate := allocate / request
rate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", rate), 64)
rate, err := strconv.ParseFloat(fmt.Sprintf("%.2f", rate), 64)
if err != nil {
logrus.Error(err)
return DistributionRate{RenderType: "text", Value: t.SDK.I18n("None")}
}
if rate <= 0.4 {
return DistributionRate{RenderType: "text", Value: t.SDK.I18n("Low"), DistributionValue: rate}
} else if rate <= 0.8 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (mt *MemInfoTable) GetProps() map[string]interface{} {
{DataIndex: "IP", Title: mt.SDK.I18n("ip"), Sortable: true},
{DataIndex: "Role", Title: "Role", Sortable: true},
{DataIndex: "Version", Title: mt.SDK.I18n("version"), Sortable: true},
{DataIndex: "Operate", Title: mt.SDK.I18n("podsList"), Fixed: "right"},
{DataIndex: "Operate", Title: mt.SDK.I18n("operate"), Fixed: "right"},
},
"selectable": true,
"pageSizeOptions": []string{"10", "20", "50", "100"},
Expand Down
1 change: 1 addition & 0 deletions modules/cmp/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ func (m *Metric) Store(response *pb.QueryWithInfluxFormatResponse, metricsReques
d = &MetricsData{
Used: row.Values[2].GetNumberValue(),
}
logrus.Info(k, "=====", d.Used)
SetCache(k, d)
res[k] = d
}
Expand Down

0 comments on commit 94449aa

Please sign in to comment.