vendor: update google/cadvisor and opencontainers/runc
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
3
vendor/github.com/google/cadvisor/manager/BUILD
generated
vendored
3
vendor/github.com/google/cadvisor/manager/BUILD
generated
vendored
@@ -24,6 +24,7 @@ go_library(
|
||||
"//vendor/github.com/google/cadvisor/machine:go_default_library",
|
||||
"//vendor/github.com/google/cadvisor/nvm:go_default_library",
|
||||
"//vendor/github.com/google/cadvisor/perf:go_default_library",
|
||||
"//vendor/github.com/google/cadvisor/resctrl:go_default_library",
|
||||
"//vendor/github.com/google/cadvisor/stats:go_default_library",
|
||||
"//vendor/github.com/google/cadvisor/summary:go_default_library",
|
||||
"//vendor/github.com/google/cadvisor/utils/cpuload:go_default_library",
|
||||
@@ -32,6 +33,8 @@ go_library(
|
||||
"//vendor/github.com/google/cadvisor/version:go_default_library",
|
||||
"//vendor/github.com/google/cadvisor/watcher:go_default_library",
|
||||
"//vendor/github.com/opencontainers/runc/libcontainer/cgroups:go_default_library",
|
||||
"//vendor/github.com/opencontainers/runc/libcontainer/cgroups/fs2:go_default_library",
|
||||
"//vendor/github.com/opencontainers/runc/libcontainer/intelrdt:go_default_library",
|
||||
"//vendor/k8s.io/klog/v2:go_default_library",
|
||||
"//vendor/k8s.io/utils/clock:go_default_library",
|
||||
],
|
||||
|
24
vendor/github.com/google/cadvisor/manager/container.go
generated
vendored
24
vendor/github.com/google/cadvisor/manager/container.go
generated
vendored
@@ -94,6 +94,9 @@ type containerData struct {
|
||||
|
||||
// perfCollector updates stats for perf_event cgroup controller.
|
||||
perfCollector stats.Collector
|
||||
|
||||
// resctrlCollector updates stats for resctrl controller.
|
||||
resctrlCollector stats.Collector
|
||||
}
|
||||
|
||||
// jitter returns a time.Duration between duration and duration + maxFactor * duration,
|
||||
@@ -159,7 +162,7 @@ func (cd *containerData) notifyOnDemand() {
|
||||
|
||||
func (cd *containerData) GetInfo(shouldUpdateSubcontainers bool) (*containerInfo, error) {
|
||||
// Get spec and subcontainers.
|
||||
if cd.clock.Since(cd.infoLastUpdatedTime) > 5*time.Second {
|
||||
if cd.clock.Since(cd.infoLastUpdatedTime) > 5*time.Second || shouldUpdateSubcontainers {
|
||||
err := cd.updateSpec()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -286,12 +289,12 @@ func (cd *containerData) GetProcessList(cadvisorContainer string, inHostNamespac
|
||||
if !inHostNamespace {
|
||||
rootfs = "/rootfs"
|
||||
}
|
||||
format := "user,pid,ppid,stime,pcpu,pmem,rss,vsz,stat,time,comm,cgroup"
|
||||
format := "user,pid,ppid,stime,pcpu,pmem,rss,vsz,stat,time,comm,psr,cgroup"
|
||||
out, err := cd.getPsOutput(inHostNamespace, format)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
expectedFields := 12
|
||||
expectedFields := 13
|
||||
processes := []v2.ProcessInfo{}
|
||||
lines := strings.Split(string(out), "\n")
|
||||
for _, line := range lines[1:] {
|
||||
@@ -330,7 +333,12 @@ func (cd *containerData) GetProcessList(cadvisorContainer string, inHostNamespac
|
||||
}
|
||||
// convert to bytes
|
||||
vs *= 1024
|
||||
cgroup, err := cd.getCgroupPath(fields[11])
|
||||
psr, err := strconv.Atoi(fields[11])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid pid %q: %v", fields[1], err)
|
||||
}
|
||||
|
||||
cgroup, err := cd.getCgroupPath(fields[12])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not parse cgroup path from %q: %v", fields[11], err)
|
||||
}
|
||||
@@ -368,6 +376,7 @@ func (cd *containerData) GetProcessList(cadvisorContainer string, inHostNamespac
|
||||
Cmd: fields[10],
|
||||
CgroupPath: cgroupPath,
|
||||
FdCount: fdCount,
|
||||
Psr: psr,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -400,6 +409,7 @@ func newContainerData(containerName string, memoryCache *memory.InMemoryCache, h
|
||||
clock: clock,
|
||||
perfCollector: &stats.NoopCollector{},
|
||||
nvidiaCollector: &stats.NoopCollector{},
|
||||
resctrlCollector: &stats.NoopCollector{},
|
||||
}
|
||||
cont.info.ContainerReference = ref
|
||||
|
||||
@@ -641,6 +651,8 @@ func (cd *containerData) updateStats() error {
|
||||
|
||||
perfStatsErr := cd.perfCollector.UpdateStats(stats)
|
||||
|
||||
resctrlStatsErr := cd.resctrlCollector.UpdateStats(stats)
|
||||
|
||||
ref, err := cd.handler.ContainerReference()
|
||||
if err != nil {
|
||||
// Ignore errors if the container is dead.
|
||||
@@ -669,6 +681,10 @@ func (cd *containerData) updateStats() error {
|
||||
klog.Errorf("error occurred while collecting perf stats for container %s: %s", cInfo.Name, err)
|
||||
return perfStatsErr
|
||||
}
|
||||
if resctrlStatsErr != nil {
|
||||
klog.Errorf("error occurred while collecting resctrl stats for container %s: %s", cInfo.Name, err)
|
||||
return resctrlStatsErr
|
||||
}
|
||||
return customStatsErr
|
||||
}
|
||||
|
||||
|
55
vendor/github.com/google/cadvisor/manager/manager.go
generated
vendored
55
vendor/github.com/google/cadvisor/manager/manager.go
generated
vendored
@@ -18,6 +18,7 @@ package manager
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/opencontainers/runc/libcontainer/cgroups/fs2"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
@@ -39,6 +40,7 @@ import (
|
||||
"github.com/google/cadvisor/machine"
|
||||
"github.com/google/cadvisor/nvm"
|
||||
"github.com/google/cadvisor/perf"
|
||||
"github.com/google/cadvisor/resctrl"
|
||||
"github.com/google/cadvisor/stats"
|
||||
"github.com/google/cadvisor/utils/oomparser"
|
||||
"github.com/google/cadvisor/utils/sysfs"
|
||||
@@ -46,6 +48,8 @@ import (
|
||||
"github.com/google/cadvisor/watcher"
|
||||
|
||||
"github.com/opencontainers/runc/libcontainer/cgroups"
|
||||
"github.com/opencontainers/runc/libcontainer/intelrdt"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/utils/clock"
|
||||
)
|
||||
@@ -148,11 +152,18 @@ func New(memoryCache *memory.InMemoryCache, sysfs sysfs.SysFs, houskeepingConfig
|
||||
}
|
||||
|
||||
// Detect the container we are running on.
|
||||
selfContainer, err := cgroups.GetOwnCgroupPath("cpu")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
selfContainer := "/"
|
||||
var err error
|
||||
// Avoid using GetOwnCgroupPath on cgroup v2 as it is not supported by libcontainer
|
||||
if cgroups.IsCgroup2UnifiedMode() {
|
||||
klog.Warningf("Cannot detect current cgroup on cgroup v2")
|
||||
} else {
|
||||
selfContainer, err := cgroups.GetOwnCgroupPath("cpu")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
klog.V(2).Infof("cAdvisor running in container: %q", selfContainer)
|
||||
}
|
||||
klog.V(2).Infof("cAdvisor running in container: %q", selfContainer)
|
||||
|
||||
context := fs.Context{}
|
||||
|
||||
@@ -190,7 +201,7 @@ func New(memoryCache *memory.InMemoryCache, sysfs sysfs.SysFs, houskeepingConfig
|
||||
containerWatchers: []watcher.ContainerWatcher{},
|
||||
eventsChannel: eventsChannel,
|
||||
collectorHTTPClient: collectorHTTPClient,
|
||||
nvidiaManager: accelerators.NewNvidiaManager(),
|
||||
nvidiaManager: accelerators.NewNvidiaManager(includedMetricsSet),
|
||||
rawContainerCgroupPathPrefixWhiteList: rawContainerCgroupPathPrefixWhiteList,
|
||||
}
|
||||
|
||||
@@ -201,11 +212,16 @@ func New(memoryCache *memory.InMemoryCache, sysfs sysfs.SysFs, houskeepingConfig
|
||||
newManager.machineInfo = *machineInfo
|
||||
klog.V(1).Infof("Machine: %+v", newManager.machineInfo)
|
||||
|
||||
newManager.perfManager, err = perf.NewManager(perfEventsFile, machineInfo.NumCores)
|
||||
newManager.perfManager, err = perf.NewManager(perfEventsFile, machineInfo.NumCores, machineInfo.Topology)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
newManager.resctrlManager, err = resctrl.NewManager(selfContainer)
|
||||
if err != nil {
|
||||
klog.V(4).Infof("Cannot gather resctrl metrics: %v", err)
|
||||
}
|
||||
|
||||
versionInfo, err := getVersionInfo()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -246,6 +262,7 @@ type manager struct {
|
||||
collectorHTTPClient *http.Client
|
||||
nvidiaManager stats.Manager
|
||||
perfManager stats.Manager
|
||||
resctrlManager stats.Manager
|
||||
// List of raw container cgroup path prefix whitelist.
|
||||
rawContainerCgroupPathPrefixWhiteList []string
|
||||
}
|
||||
@@ -545,6 +562,9 @@ func (m *manager) getSubcontainers(containerName string) map[string]*containerDa
|
||||
// Get all the unique subcontainers of the specified container
|
||||
matchedName := path.Join(containerName, "/")
|
||||
for i := range m.containers {
|
||||
if m.containers[i] == nil {
|
||||
continue
|
||||
}
|
||||
name := m.containers[i].info.Name
|
||||
if name == containerName || strings.HasPrefix(name, matchedName) {
|
||||
containersMap[m.containers[i].info.Name] = m.containers[i]
|
||||
@@ -650,6 +670,7 @@ func (m *manager) containerDataSliceToContainerInfoSlice(containers []*container
|
||||
cinfo, err := m.containerDataToContainerInfo(containers[i], query)
|
||||
if err != nil {
|
||||
// Skip containers with errors, we try to degrade gracefully.
|
||||
klog.V(4).Infof("convert container data to container info failed with error %s", err.Error())
|
||||
continue
|
||||
}
|
||||
output = append(output, cinfo)
|
||||
@@ -906,7 +927,14 @@ func (m *manager) createContainerLocked(containerName string, watchSource watche
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !cgroups.IsCgroup2UnifiedMode() {
|
||||
|
||||
if cgroups.IsCgroup2UnifiedMode() {
|
||||
perfCgroupPath := path.Join(fs2.UnifiedMountpoint, containerName)
|
||||
cont.perfCollector, err = m.perfManager.GetCollector(perfCgroupPath)
|
||||
if err != nil {
|
||||
klog.Infof("perf_event metrics will not be available for container %s: %s", containerName, err)
|
||||
}
|
||||
} else {
|
||||
devicesCgroupPath, err := handler.GetCgroupPath("devices")
|
||||
if err != nil {
|
||||
klog.Warningf("Error getting devices cgroup path: %v", err)
|
||||
@@ -916,18 +944,27 @@ func (m *manager) createContainerLocked(containerName string, watchSource watche
|
||||
klog.V(4).Infof("GPU metrics may be unavailable/incomplete for container %s: %s", cont.info.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
perfCgroupPath, err := handler.GetCgroupPath("perf_event")
|
||||
if err != nil {
|
||||
klog.Warningf("Error getting perf_event cgroup path: %q", err)
|
||||
} else {
|
||||
cont.perfCollector, err = m.perfManager.GetCollector(perfCgroupPath)
|
||||
if err != nil {
|
||||
klog.Infof("perf_event metrics will not be available for container %s: %s", cont.info.Name, err)
|
||||
klog.Infof("perf_event metrics will not be available for container %s: %s", containerName, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resctrlPath, err := intelrdt.GetIntelRdtPath(containerName)
|
||||
if err != nil {
|
||||
klog.Warningf("Error getting resctrl path: %q", err)
|
||||
} else {
|
||||
cont.resctrlCollector, err = m.resctrlManager.GetCollector(resctrlPath)
|
||||
if err != nil {
|
||||
klog.Infof("resctrl metrics will not be available for container %s: %s", cont.info.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Add collectors
|
||||
labels := handler.GetContainerLabels()
|
||||
collectorConfigs := collector.GetCollectorConfigs(labels)
|
||||
|
Reference in New Issue
Block a user