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"
|
||||
}
|
||||
|
Reference in New Issue
Block a user