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

@@ -27,8 +27,6 @@ go_library(
"//vendor/github.com/google/cadvisor/fs:go_default_library",
"//vendor/github.com/google/cadvisor/info/v1:go_default_library",
"//vendor/github.com/google/cadvisor/watcher:go_default_library",
"//vendor/github.com/opencontainers/runc/libcontainer/cgroups/fs:go_default_library",
"//vendor/github.com/opencontainers/runc/libcontainer/configs:go_default_library",
"//vendor/github.com/opencontainers/runtime-spec/specs-go:go_default_library",
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/google.golang.org/grpc:go_default_library",

View File

@@ -22,8 +22,6 @@ import (
"time"
"github.com/containerd/containerd/errdefs"
cgroupfs "github.com/opencontainers/runc/libcontainer/cgroups/fs"
libcontainerconfigs "github.com/opencontainers/runc/libcontainer/configs"
"golang.org/x/net/context"
"github.com/google/cadvisor/container"
@@ -69,11 +67,9 @@ func newContainerdContainerHandler(
cgroupPaths := common.MakeCgroupPaths(cgroupSubsystems.MountPoints, name)
// Generate the equivalent cgroup manager for this container.
cgroupManager := &cgroupfs.Manager{
Cgroups: &libcontainerconfigs.Cgroup{
Name: name,
},
Paths: cgroupPaths,
cgroupManager, err := containerlibcontainer.NewCgroupManager(name, cgroupPaths)
if err != nil {
return nil, err
}
id := ContainerNameToContainerdID(name)

View File

@@ -18,8 +18,7 @@ go_library(
"//vendor/github.com/google/cadvisor/fs:go_default_library",
"//vendor/github.com/google/cadvisor/info/v1:go_default_library",
"//vendor/github.com/google/cadvisor/watcher:go_default_library",
"//vendor/github.com/opencontainers/runc/libcontainer/cgroups/fs:go_default_library",
"//vendor/github.com/opencontainers/runc/libcontainer/configs:go_default_library",
"//vendor/github.com/opencontainers/runc/libcontainer/cgroups:go_default_library",
"//vendor/k8s.io/klog/v2:go_default_library",
],
)

View File

@@ -26,9 +26,7 @@ import (
containerlibcontainer "github.com/google/cadvisor/container/libcontainer"
"github.com/google/cadvisor/fs"
info "github.com/google/cadvisor/info/v1"
cgroupfs "github.com/opencontainers/runc/libcontainer/cgroups/fs"
libcontainerconfigs "github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/cgroups"
)
type crioContainerHandler struct {
@@ -70,7 +68,7 @@ type crioContainerHandler struct {
reference info.ContainerReference
libcontainerHandler *containerlibcontainer.Handler
cgroupManager *cgroupfs.Manager
cgroupManager cgroups.Manager
rootFs string
pidKnown bool
}
@@ -94,11 +92,9 @@ func newCrioContainerHandler(
cgroupPaths := common.MakeCgroupPaths(cgroupSubsystems.MountPoints, name)
// Generate the equivalent cgroup manager for this container.
cgroupManager := &cgroupfs.Manager{
Cgroups: &libcontainerconfigs.Cgroup{
Name: name,
},
Paths: cgroupPaths,
cgroupManager, err := containerlibcontainer.NewCgroupManager(name, cgroupPaths)
if err != nil {
return nil, err
}
rootFs := "/"

View File

@@ -28,8 +28,6 @@ go_library(
"//vendor/github.com/google/cadvisor/machine:go_default_library",
"//vendor/github.com/google/cadvisor/watcher:go_default_library",
"//vendor/github.com/google/cadvisor/zfs:go_default_library",
"//vendor/github.com/opencontainers/runc/libcontainer/cgroups/fs:go_default_library",
"//vendor/github.com/opencontainers/runc/libcontainer/configs:go_default_library",
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/k8s.io/klog/v2:go_default_library",
],

View File

@@ -34,8 +34,6 @@ import (
dockercontainer "github.com/docker/docker/api/types/container"
docker "github.com/docker/docker/client"
cgroupfs "github.com/opencontainers/runc/libcontainer/cgroups/fs"
libcontainerconfigs "github.com/opencontainers/runc/libcontainer/configs"
"golang.org/x/net/context"
"k8s.io/klog/v2"
)
@@ -136,11 +134,9 @@ func newDockerContainerHandler(
cgroupPaths := common.MakeCgroupPaths(cgroupSubsystems.MountPoints, name)
// Generate the equivalent cgroup manager for this container.
cgroupManager := &cgroupfs.Manager{
Cgroups: &libcontainerconfigs.Cgroup{
Name: name,
},
Paths: cgroupPaths,
cgroupManager, err := containerlibcontainer.NewCgroupManager(name, cgroupPaths)
if err != nil {
return nil, err
}
rootFs := "/"

View File

@@ -61,6 +61,7 @@ const (
PerfMetrics MetricKind = "perf_event"
ReferencedMemoryMetrics MetricKind = "referenced_memory"
CPUTopologyMetrics MetricKind = "cpu_topology"
ResctrlMetrics MetricKind = "resctrl"
)
// AllMetrics represents all kinds of metrics that cAdvisor supported.
@@ -83,6 +84,7 @@ var AllMetrics = MetricSet{
PerfMetrics: struct{}{},
ReferencedMemoryMetrics: struct{}{},
CPUTopologyMetrics: struct{}{},
ResctrlMetrics: struct{}{},
}
func (mk MetricKind) String() string {

View File

@@ -14,6 +14,9 @@ go_library(
"//vendor/github.com/google/cadvisor/info/v1:go_default_library",
"//vendor/github.com/opencontainers/runc/libcontainer:go_default_library",
"//vendor/github.com/opencontainers/runc/libcontainer/cgroups:go_default_library",
"//vendor/github.com/opencontainers/runc/libcontainer/cgroups/fs:go_default_library",
"//vendor/github.com/opencontainers/runc/libcontainer/cgroups/fs2:go_default_library",
"//vendor/github.com/opencontainers/runc/libcontainer/configs:go_default_library",
"//vendor/golang.org/x/sys/unix:go_default_library",
"//vendor/k8s.io/klog/v2:go_default_library",
],

View File

@@ -16,6 +16,7 @@ package libcontainer
import (
"bufio"
"bytes"
"encoding/json"
"flag"
"fmt"
@@ -32,10 +33,9 @@ import (
info "github.com/google/cadvisor/info/v1"
"golang.org/x/sys/unix"
"bytes"
"github.com/opencontainers/runc/libcontainer"
"github.com/opencontainers/runc/libcontainer/cgroups"
fs2 "github.com/opencontainers/runc/libcontainer/cgroups/fs2"
"k8s.io/klog/v2"
)
@@ -71,9 +71,21 @@ func NewHandler(cgroupManager cgroups.Manager, rootFs string, pid int, includedM
// Get cgroup and networking stats of the specified container
func (h *Handler) GetStats() (*info.ContainerStats, error) {
cgroupStats, err := h.cgroupManager.GetStats()
if err != nil {
return nil, err
var cgroupStats *cgroups.Stats
readCgroupStats := true
if cgroups.IsCgroup2UnifiedMode() {
// On cgroup v2 there are no stats at the root cgroup
// so check whether it is the root cgroup
if h.cgroupManager.Path("") == fs2.UnifiedMountpoint {
readCgroupStats = false
}
}
var err error
if readCgroupStats {
cgroupStats, err = h.cgroupManager.GetStats()
if err != nil {
return nil, err
}
}
libcontainerStats := &libcontainer.Stats{
CgroupStats: cgroupStats,
@@ -838,8 +850,13 @@ func setMemoryStats(s *cgroups.Stats, ret *info.ContainerStats) {
ret.Memory.HierarchicalData.Pgmajfault = v
}
inactiveFileKeyName := "total_inactive_file"
if cgroups.IsCgroup2UnifiedMode() {
inactiveFileKeyName = "inactive_file"
}
workingSet := ret.Memory.Usage
if v, ok := s.MemoryStats.Stats["total_inactive_file"]; ok {
if v, ok := s.MemoryStats.Stats[inactiveFileKeyName]; ok {
if workingSet < v {
workingSet = 0
} else {

View File

@@ -21,6 +21,10 @@ import (
"github.com/google/cadvisor/container"
"github.com/opencontainers/runc/libcontainer/cgroups"
fs "github.com/opencontainers/runc/libcontainer/cgroups/fs"
fs2 "github.com/opencontainers/runc/libcontainer/cgroups/fs2"
configs "github.com/opencontainers/runc/libcontainer/configs"
"k8s.io/klog/v2"
)
@@ -165,3 +169,16 @@ func DiskStatsCopy(blkioStats []cgroups.BlkioStatEntry) (stat []info.PerDiskStat
}
return DiskStatsCopy1(diskStat)
}
func NewCgroupManager(name string, paths map[string]string) (cgroups.Manager, error) {
if cgroups.IsCgroup2UnifiedMode() {
path := paths["cpu"]
return fs2.NewManager(nil, path, false)
}
config := configs.Cgroup{
Name: name,
}
return fs.NewManager(&config, paths, false), nil
}

View File

@@ -18,8 +18,6 @@ go_library(
"//vendor/github.com/google/cadvisor/info/v1:go_default_library",
"//vendor/github.com/google/cadvisor/machine:go_default_library",
"//vendor/github.com/google/cadvisor/watcher:go_default_library",
"//vendor/github.com/opencontainers/runc/libcontainer/cgroups/fs:go_default_library",
"//vendor/github.com/opencontainers/runc/libcontainer/configs:go_default_library",
"//vendor/k8s.io/klog/v2:go_default_library",
"//vendor/k8s.io/utils/inotify:go_default_library",
],

View File

@@ -25,8 +25,6 @@ import (
info "github.com/google/cadvisor/info/v1"
"github.com/google/cadvisor/machine"
cgroupfs "github.com/opencontainers/runc/libcontainer/cgroups/fs"
"github.com/opencontainers/runc/libcontainer/configs"
"k8s.io/klog/v2"
)
@@ -51,19 +49,16 @@ func isRootCgroup(name string) bool {
}
func newRawContainerHandler(name string, cgroupSubsystems *libcontainer.CgroupSubsystems, machineInfoFactory info.MachineInfoFactory, fsInfo fs.FsInfo, watcher *common.InotifyWatcher, rootFs string, includedMetrics container.MetricSet) (container.ContainerHandler, error) {
cgroupPaths := common.MakeCgroupPaths(cgroupSubsystems.MountPoints, name)
cHints, err := common.GetContainerHintsFromFile(*common.ArgContainerHints)
if err != nil {
return nil, err
}
// Generate the equivalent cgroup manager for this container.
cgroupManager := &cgroupfs.Manager{
Cgroups: &configs.Cgroup{
Name: name,
},
Paths: cgroupPaths,
cgroupPaths := common.MakeCgroupPaths(cgroupSubsystems.MountPoints, name)
cgroupManager, err := libcontainer.NewCgroupManager(name, cgroupPaths)
if err != nil {
return nil, err
}
var externalMounts []common.Mount
@@ -192,13 +187,18 @@ func fsToFsStats(fs *fs.Fs) info.FsStats {
func (h *rawContainerHandler) getFsStats(stats *info.ContainerStats) error {
var filesystems []fs.Fs
var err error
// Early exist if no disk metrics are to be collected.
if !h.includedMetrics.Has(container.DiskUsageMetrics) && !h.includedMetrics.Has(container.DiskIOMetrics) {
return nil
}
// Get Filesystem information only for the root cgroup.
if isRootCgroup(h.name) {
filesystems, err = h.fsInfo.GetGlobalFsInfo()
if err != nil {
return err
}
} else if h.includedMetrics.Has(container.DiskUsageMetrics) || h.includedMetrics.Has(container.DiskIOMetrics) {
} else {
if len(h.externalMounts) > 0 {
mountSet := make(map[string]struct{})
for _, mount := range h.externalMounts {
@@ -211,14 +211,14 @@ func (h *rawContainerHandler) getFsStats(stats *info.ContainerStats) error {
}
}
if isRootCgroup(h.name) || h.includedMetrics.Has(container.DiskUsageMetrics) {
if h.includedMetrics.Has(container.DiskUsageMetrics) {
for i := range filesystems {
fs := filesystems[i]
stats.Filesystem = append(stats.Filesystem, fsToFsStats(&fs))
}
}
if isRootCgroup(h.name) || h.includedMetrics.Has(container.DiskIOMetrics) {
if h.includedMetrics.Has(container.DiskIOMetrics) {
common.AssignDeviceNamesToDiskStats(&fsNamer{fs: filesystems, factory: h.machineInfoFactory}, &stats.DiskIo)
}