Skip to content

Commit

Permalink
Merge pull request kubernetes-retired#693 from mwielgus/fix-npe
Browse files Browse the repository at this point in the history
Fix nil pointer reference panic in kube_nodes
  • Loading branch information
mwielgus committed Nov 6, 2015
2 parents ad35589 + 0803331 commit 0b42d6f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sources/kube_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ func (self *kubeNodeMetrics) updateStats(host nodes.Host, info nodes.Info, start
hostCopy := containers[hostIndex]
hostContainer = &hostCopy
containers = append(containers[:hostIndex], containers[hostIndex+1:]...)
// This is temporary workaround for #399. To make unit consistent with cadvisor normalize to a conversion factor of 1024.
hostContainer.Spec.Cpu.Limit = info.CpuCapacity * 1024 / 1000
hostContainer.Spec.Memory.Limit = info.MemCapacity
return hostContainer, containers, nil
} else {
return nil, []api.Container{}, fmt.Errorf("Host container not found")
}
// This is temporary workaround for #399. To make unit consistent with cadvisor normalize to a conversion factor of 1024.
hostContainer.Spec.Cpu.Limit = info.CpuCapacity * 1024 / 1000
hostContainer.Spec.Memory.Limit = info.MemCapacity
return hostContainer, containers, nil
}

// Returns the host containers, non-Kubernetes containers, and an error (if any).
Expand Down

0 comments on commit 0b42d6f

Please sign in to comment.