Skip to content

Commit

Permalink
bugfix of populating nodes stats (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiejingru authored Apr 29, 2021
1 parent be844e3 commit df44178
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion spec/v1/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,12 @@ func (view *NodeView) populateNodeStats(timeout time.Duration) (err error) {
if stats := view.Report.NodeStats; stats != nil {
for _, s := range stats {
s.Percent = map[string]string{}
if s.Capacity == nil {
s.Capacity = map[string]string{}
}
if s.Usage == nil {
s.Usage = map[string]string{}
}
memory := string(coreV1.ResourceMemory)
if s.Percent[memory], err = s.processResourcePercent(s, memory, populateMemoryResource); err != nil {
return errors.Trace(err)
Expand All @@ -383,7 +389,10 @@ func (view *NodeView) populateNodeStats(timeout time.Duration) (err error) {
}

func populateGPUStats(s *NodeStats, extension interface{}) {
stats, _ := extension.(map[string]interface{})
stats, ok := extension.(map[string]interface{})
if !ok {
return
}
if val, ok := stats[KeyGPUUsedMemory]; ok {
used, _ := val.(float64)
s.Usage[ResourceGPU] = strconv.FormatFloat(used, 'f', -1, 64)
Expand Down

0 comments on commit df44178

Please sign in to comment.