vendor: update google/cadvisor and opencontainers/runc
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
1
vendor/github.com/google/cadvisor/utils/sysfs/BUILD
generated
vendored
1
vendor/github.com/google/cadvisor/utils/sysfs/BUILD
generated
vendored
@@ -6,6 +6,7 @@ go_library(
|
||||
importmap = "k8s.io/kubernetes/vendor/github.com/google/cadvisor/utils/sysfs",
|
||||
importpath = "github.com/google/cadvisor/utils/sysfs",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["//vendor/k8s.io/klog/v2:go_default_library"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
|
31
vendor/github.com/google/cadvisor/utils/sysfs/sysfs.go
generated
vendored
31
vendor/github.com/google/cadvisor/utils/sysfs/sysfs.go
generated
vendored
@@ -15,13 +15,18 @@
|
||||
package sysfs
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -95,6 +100,9 @@ type SysFs interface {
|
||||
GetCacheInfo(cpu int, cache string) (CacheInfo, error)
|
||||
|
||||
GetSystemUUID() (string, error)
|
||||
// IsCPUOnline determines if CPU status from kernel hotplug machanism standpoint.
|
||||
// See: https://www.kernel.org/doc/html/latest/core-api/cpu_hotplug.html
|
||||
IsCPUOnline(dir string) bool
|
||||
}
|
||||
|
||||
type realSysFs struct{}
|
||||
@@ -326,3 +334,26 @@ func (fs *realSysFs) GetSystemUUID() (string, error) {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
func (fs *realSysFs) IsCPUOnline(dir string) bool {
|
||||
cpuPath := fmt.Sprintf("%s/online", dir)
|
||||
content, err := ioutil.ReadFile(cpuPath)
|
||||
if err != nil {
|
||||
pathErr, ok := err.(*os.PathError)
|
||||
if ok {
|
||||
if errors.Is(pathErr.Unwrap(), os.ErrNotExist) && isZeroCPU(dir) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
klog.Warningf("unable to read %s: %s", cpuPath, err.Error())
|
||||
return false
|
||||
}
|
||||
trimmed := bytes.TrimSpace(content)
|
||||
return len(trimmed) == 1 && trimmed[0] == 49
|
||||
}
|
||||
|
||||
func isZeroCPU(dir string) bool {
|
||||
regex := regexp.MustCompile("cpu([0-9]*)")
|
||||
matches := regex.FindStringSubmatch(dir)
|
||||
return len(matches) == 2 && matches[1] == "0"
|
||||
}
|
||||
|
53
vendor/github.com/google/cadvisor/utils/sysinfo/sysinfo.go
generated
vendored
53
vendor/github.com/google/cadvisor/utils/sysinfo/sysinfo.go
generated
vendored
@@ -16,6 +16,7 @@ package sysinfo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -219,15 +220,16 @@ func GetNodesInfo(sysFs sysfs.SysFs) ([]info.Node, int, error) {
|
||||
return nil, 0, err
|
||||
}
|
||||
node.Cores = cores
|
||||
for _, core := range cores {
|
||||
allLogicalCoresCount += len(core.Threads)
|
||||
}
|
||||
}
|
||||
|
||||
allLogicalCoresCount += len(cpuDirs)
|
||||
|
||||
// On some Linux platforms(such as Arm64 guest kernel), cache info may not exist.
|
||||
// So, we should ignore error here.
|
||||
err = addCacheInfo(sysFs, &node)
|
||||
if err != nil {
|
||||
klog.Warningf("Found node without cache information, nodeDir: %s", nodeDir)
|
||||
klog.V(1).Infof("Found node without cache information, nodeDir: %s", nodeDir)
|
||||
}
|
||||
|
||||
node.Memory, err = getNodeMemInfo(sysFs, nodeDir)
|
||||
@@ -265,6 +267,11 @@ func getCPUTopology(sysFs sysfs.SysFs) ([]info.Node, int, error) {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
if len(cpusByPhysicalPackageID) == 0 {
|
||||
klog.Warningf("Cannot read any physical package id for any CPU")
|
||||
return nil, cpusCount, nil
|
||||
}
|
||||
|
||||
for physicalPackageID, cpus := range cpusByPhysicalPackageID {
|
||||
node := info.Node{Id: physicalPackageID}
|
||||
|
||||
@@ -278,7 +285,7 @@ func getCPUTopology(sysFs sysfs.SysFs) ([]info.Node, int, error) {
|
||||
// So, we should ignore error here.
|
||||
err = addCacheInfo(sysFs, &node)
|
||||
if err != nil {
|
||||
klog.Warningf("Found cpu without cache information, cpuPath: %s", cpus)
|
||||
klog.V(1).Infof("Found cpu without cache information, cpuPath: %s", cpus)
|
||||
}
|
||||
nodes = append(nodes, node)
|
||||
}
|
||||
@@ -290,7 +297,10 @@ func getCpusByPhysicalPackageID(sysFs sysfs.SysFs, cpusPaths []string) (map[int]
|
||||
for _, cpuPath := range cpusPaths {
|
||||
|
||||
rawPhysicalPackageID, err := sysFs.GetCPUPhysicalPackageID(cpuPath)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
klog.Warningf("Cannot read physical package id for %s, physical_package_id file does not exist, err: %s", cpuPath, err)
|
||||
continue
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -375,9 +385,15 @@ func getCoresInfo(sysFs sysfs.SysFs, cpuDirs []string) ([]info.Core, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unexpected format of CPU directory, cpuDirRegExp %s, cpuDir: %s", cpuDirRegExp, cpuDir)
|
||||
}
|
||||
if !sysFs.IsCPUOnline(cpuDir) {
|
||||
continue
|
||||
}
|
||||
|
||||
rawPhysicalID, err := sysFs.GetCoreID(cpuDir)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
klog.Warningf("Cannot read core id for %s, core_id file does not exist, err: %s", cpuDir, err)
|
||||
continue
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
physicalID, err := strconv.Atoi(rawPhysicalID)
|
||||
@@ -403,6 +419,20 @@ func getCoresInfo(sysFs sysfs.SysFs, cpuDirs []string) ([]info.Core, error) {
|
||||
} else {
|
||||
desiredCore.Threads = append(desiredCore.Threads, cpuID)
|
||||
}
|
||||
|
||||
rawPhysicalPackageID, err := sysFs.GetCPUPhysicalPackageID(cpuDir)
|
||||
if os.IsNotExist(err) {
|
||||
klog.Warningf("Cannot read physical package id for %s, physical_package_id file does not exist, err: %s", cpuDir, err)
|
||||
continue
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
physicalPackageID, err := strconv.Atoi(rawPhysicalPackageID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
desiredCore.SocketID = physicalPackageID
|
||||
}
|
||||
return cores, nil
|
||||
}
|
||||
@@ -482,3 +512,14 @@ func getMatchedInt(rgx *regexp.Regexp, str string) (int, error) {
|
||||
}
|
||||
return valInt, nil
|
||||
}
|
||||
|
||||
// GetSocketFromCPU returns Socket ID of passed CPU. If is not present, returns -1.
|
||||
func GetSocketFromCPU(topology []info.Node, cpu int) int {
|
||||
for _, node := range topology {
|
||||
found, coreID := node.FindCoreByThread(cpu)
|
||||
if found {
|
||||
return node.Cores[coreID].SocketID
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
Reference in New Issue
Block a user