The gopsutil cpu implementation changed in v3

Was supposed to return the number of vCPU (i.e. nproc)
Before, both "physical" and "logical" returned the same.

The returned information should match cpuinfo and lscpu:
    CPU(s) = Socket(s) x Core(s) each x Thread(s) each
pull/10270/head
Anders F Björklund 2021-01-26 17:45:32 +01:00
parent c2bb8385d6
commit 7e9d58c468
2 changed files with 3 additions and 2 deletions

View File

@ -979,8 +979,8 @@ func validateCPUCount(drvName string) {
var cpuCount int
if driver.BareMetal(drvName) {
// Uses the gopsutil cpu package to count the number of physical cpu cores
ci, err := cpu.Counts(false)
// Uses the gopsutil cpu package to count the number of logical cpu cores
ci, err := cpu.Counts(true)
if err != nil {
klog.Warningf("Unable to get CPU info: %v", err)
} else {

View File

@ -181,6 +181,7 @@ var (
// cachedCPUInfo will return a cached cpu info
func cachedCPUInfo() ([]cpu.InfoStat, error) {
if cachedCPU == nil {
// one InfoStat per thread
i, err := cpu.Info()
cachedCPU = &i
cachedCPUErr = &err