vendor: update google/cadvisor and opencontainers/runc

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano
2020-06-24 10:56:34 +02:00
parent 78d295d168
commit a6a3bf2eb4
632 changed files with 36493 additions and 89280 deletions

View File

@@ -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(

View File

@@ -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"
}