update cAdvisor to v0.37.0
This commit is contained in:
92
vendor/github.com/google/cadvisor/container/libcontainer/handler.go
generated
vendored
92
vendor/github.com/google/cadvisor/container/libcontainer/handler.go
generated
vendored
@@ -118,56 +118,58 @@ func (h *Handler) GetStats() (*info.ContainerStats, error) {
|
||||
}
|
||||
|
||||
// If we know the pid then get network stats from /proc/<pid>/net/dev
|
||||
if h.pid == 0 {
|
||||
return stats, nil
|
||||
}
|
||||
if h.includedMetrics.Has(container.NetworkUsageMetrics) {
|
||||
netStats, err := networkStatsFromProc(h.rootFs, h.pid)
|
||||
if err != nil {
|
||||
klog.V(4).Infof("Unable to get network stats from pid %d: %v", h.pid, err)
|
||||
} else {
|
||||
stats.Network.Interfaces = append(stats.Network.Interfaces, netStats...)
|
||||
}
|
||||
}
|
||||
if h.includedMetrics.Has(container.NetworkTcpUsageMetrics) {
|
||||
t, err := tcpStatsFromProc(h.rootFs, h.pid, "net/tcp")
|
||||
if err != nil {
|
||||
klog.V(4).Infof("Unable to get tcp stats from pid %d: %v", h.pid, err)
|
||||
} else {
|
||||
stats.Network.Tcp = t
|
||||
if h.pid > 0 {
|
||||
if h.includedMetrics.Has(container.NetworkUsageMetrics) {
|
||||
netStats, err := networkStatsFromProc(h.rootFs, h.pid)
|
||||
if err != nil {
|
||||
klog.V(4).Infof("Unable to get network stats from pid %d: %v", h.pid, err)
|
||||
} else {
|
||||
stats.Network.Interfaces = append(stats.Network.Interfaces, netStats...)
|
||||
}
|
||||
}
|
||||
if h.includedMetrics.Has(container.NetworkTcpUsageMetrics) {
|
||||
t, err := tcpStatsFromProc(h.rootFs, h.pid, "net/tcp")
|
||||
if err != nil {
|
||||
klog.V(4).Infof("Unable to get tcp stats from pid %d: %v", h.pid, err)
|
||||
} else {
|
||||
stats.Network.Tcp = t
|
||||
}
|
||||
|
||||
t6, err := tcpStatsFromProc(h.rootFs, h.pid, "net/tcp6")
|
||||
if err != nil {
|
||||
klog.V(4).Infof("Unable to get tcp6 stats from pid %d: %v", h.pid, err)
|
||||
} else {
|
||||
stats.Network.Tcp6 = t6
|
||||
}
|
||||
t6, err := tcpStatsFromProc(h.rootFs, h.pid, "net/tcp6")
|
||||
if err != nil {
|
||||
klog.V(4).Infof("Unable to get tcp6 stats from pid %d: %v", h.pid, err)
|
||||
} else {
|
||||
stats.Network.Tcp6 = t6
|
||||
}
|
||||
|
||||
}
|
||||
if h.includedMetrics.Has(container.NetworkAdvancedTcpUsageMetrics) {
|
||||
ta, err := advancedTCPStatsFromProc(h.rootFs, h.pid, "net/netstat", "net/snmp")
|
||||
if err != nil {
|
||||
klog.V(4).Infof("Unable to get advanced tcp stats from pid %d: %v", h.pid, err)
|
||||
} else {
|
||||
stats.Network.TcpAdvanced = ta
|
||||
}
|
||||
}
|
||||
if h.includedMetrics.Has(container.NetworkUdpUsageMetrics) {
|
||||
u, err := udpStatsFromProc(h.rootFs, h.pid, "net/udp")
|
||||
if err != nil {
|
||||
klog.V(4).Infof("Unable to get udp stats from pid %d: %v", h.pid, err)
|
||||
} else {
|
||||
stats.Network.Udp = u
|
||||
if h.includedMetrics.Has(container.NetworkAdvancedTcpUsageMetrics) {
|
||||
ta, err := advancedTCPStatsFromProc(h.rootFs, h.pid, "net/netstat", "net/snmp")
|
||||
if err != nil {
|
||||
klog.V(4).Infof("Unable to get advanced tcp stats from pid %d: %v", h.pid, err)
|
||||
} else {
|
||||
stats.Network.TcpAdvanced = ta
|
||||
}
|
||||
}
|
||||
if h.includedMetrics.Has(container.NetworkUdpUsageMetrics) {
|
||||
u, err := udpStatsFromProc(h.rootFs, h.pid, "net/udp")
|
||||
if err != nil {
|
||||
klog.V(4).Infof("Unable to get udp stats from pid %d: %v", h.pid, err)
|
||||
} else {
|
||||
stats.Network.Udp = u
|
||||
}
|
||||
|
||||
u6, err := udpStatsFromProc(h.rootFs, h.pid, "net/udp6")
|
||||
if err != nil {
|
||||
klog.V(4).Infof("Unable to get udp6 stats from pid %d: %v", h.pid, err)
|
||||
} else {
|
||||
stats.Network.Udp6 = u6
|
||||
u6, err := udpStatsFromProc(h.rootFs, h.pid, "net/udp6")
|
||||
if err != nil {
|
||||
klog.V(4).Infof("Unable to get udp6 stats from pid %d: %v", h.pid, err)
|
||||
} else {
|
||||
stats.Network.Udp6 = u6
|
||||
}
|
||||
}
|
||||
}
|
||||
// some process metrics are per container ( number of processes, number of
|
||||
// file descriptors etc.) and not required a proper container's
|
||||
// root PID (systemd services don't have the root PID atm)
|
||||
if h.includedMetrics.Has(container.ProcessMetrics) {
|
||||
paths := h.cgroupManager.GetPaths()
|
||||
path, ok := paths["cpu"]
|
||||
@@ -298,13 +300,15 @@ func processStatsFromProcs(rootFs string, cgroupPath string, rootPid int) (info.
|
||||
}
|
||||
}
|
||||
}
|
||||
ulimits := processRootProcUlimits(rootFs, rootPid)
|
||||
|
||||
processStats := info.ProcessStats{
|
||||
ProcessCount: uint64(len(pids)),
|
||||
FdCount: fdCount,
|
||||
SocketCount: socketCount,
|
||||
Ulimits: ulimits,
|
||||
}
|
||||
|
||||
if rootPid > 0 {
|
||||
processStats.Ulimits = processRootProcUlimits(rootFs, rootPid)
|
||||
}
|
||||
|
||||
return processStats, nil
|
||||
|
2
vendor/github.com/google/cadvisor/info/v2/container.go
generated
vendored
2
vendor/github.com/google/cadvisor/info/v2/container.go
generated
vendored
@@ -19,7 +19,7 @@ import (
|
||||
|
||||
// TODO(rjnagal): Remove dependency after moving all stats structs from v1.
|
||||
// using v1 now for easy conversion.
|
||||
"github.com/google/cadvisor/info/v1"
|
||||
v1 "github.com/google/cadvisor/info/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
|
2
vendor/github.com/google/cadvisor/manager/container.go
generated
vendored
2
vendor/github.com/google/cadvisor/manager/container.go
generated
vendored
@@ -33,7 +33,7 @@ import (
|
||||
"github.com/google/cadvisor/collector"
|
||||
"github.com/google/cadvisor/container"
|
||||
info "github.com/google/cadvisor/info/v1"
|
||||
"github.com/google/cadvisor/info/v2"
|
||||
v2 "github.com/google/cadvisor/info/v2"
|
||||
"github.com/google/cadvisor/stats"
|
||||
"github.com/google/cadvisor/summary"
|
||||
"github.com/google/cadvisor/utils/cpuload"
|
||||
|
20
vendor/github.com/google/cadvisor/manager/manager.go
generated
vendored
20
vendor/github.com/google/cadvisor/manager/manager.go
generated
vendored
@@ -18,7 +18,6 @@ package manager
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/opencontainers/runc/libcontainer/cgroups/fs2"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
@@ -48,6 +47,7 @@ import (
|
||||
"github.com/google/cadvisor/watcher"
|
||||
|
||||
"github.com/opencontainers/runc/libcontainer/cgroups"
|
||||
"github.com/opencontainers/runc/libcontainer/cgroups/fs2"
|
||||
"github.com/opencontainers/runc/libcontainer/intelrdt"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
@@ -932,7 +932,7 @@ func (m *manager) createContainerLocked(containerName string, watchSource watche
|
||||
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)
|
||||
klog.V(4).Infof("perf_event metrics will not be available for container %s: %s", containerName, err)
|
||||
}
|
||||
} else {
|
||||
devicesCgroupPath, err := handler.GetCgroupPath("devices")
|
||||
@@ -950,18 +950,20 @@ func (m *manager) createContainerLocked(containerName string, watchSource watche
|
||||
} else {
|
||||
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)
|
||||
klog.V(4).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 m.includedMetrics.Has(container.ResctrlMetrics) {
|
||||
resctrlPath, err := intelrdt.GetIntelRdtPath(containerName)
|
||||
if err != nil {
|
||||
klog.Infof("resctrl metrics will not be available for container %s: %s", cont.info.Name, err)
|
||||
klog.V(4).Infof("Error getting resctrl path: %q", err)
|
||||
} else {
|
||||
cont.resctrlCollector, err = m.resctrlManager.GetCollector(resctrlPath)
|
||||
if err != nil {
|
||||
klog.V(4).Infof("resctrl metrics will not be available for container %s: %s", cont.info.Name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
1
vendor/github.com/google/cadvisor/metrics/BUILD
generated
vendored
1
vendor/github.com/google/cadvisor/metrics/BUILD
generated
vendored
@@ -14,6 +14,7 @@ go_library(
|
||||
deps = [
|
||||
"//vendor/github.com/google/cadvisor/container:go_default_library",
|
||||
"//vendor/github.com/google/cadvisor/info/v1:go_default_library",
|
||||
"//vendor/github.com/google/cadvisor/info/v2:go_default_library",
|
||||
"//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
|
||||
"//vendor/k8s.io/klog/v2:go_default_library",
|
||||
"//vendor/k8s.io/utils/clock:go_default_library",
|
||||
|
6
vendor/github.com/google/cadvisor/metrics/metrics.go
generated
vendored
6
vendor/github.com/google/cadvisor/metrics/metrics.go
generated
vendored
@@ -18,6 +18,7 @@ import (
|
||||
"time"
|
||||
|
||||
info "github.com/google/cadvisor/info/v1"
|
||||
v2 "github.com/google/cadvisor/info/v2"
|
||||
)
|
||||
|
||||
// metricValue describes a single metric value for a given set of label values
|
||||
@@ -32,9 +33,8 @@ type metricValues []metricValue
|
||||
|
||||
// infoProvider will usually be manager.Manager, but can be swapped out for testing.
|
||||
type infoProvider interface {
|
||||
// SubcontainersInfo provides information about all subcontainers of the
|
||||
// specified container including itself.
|
||||
SubcontainersInfo(containerName string, query *info.ContainerInfoRequest) ([]*info.ContainerInfo, error)
|
||||
// GetRequestedContainersInfo gets info for all requested containers based on the request options.
|
||||
GetRequestedContainersInfo(containerName string, options v2.RequestOptions) (map[string]*info.ContainerInfo, error)
|
||||
// GetVersionInfo provides information about the version.
|
||||
GetVersionInfo() (*info.VersionInfo, error)
|
||||
// GetMachineInfo provides information about the machine.
|
||||
|
7
vendor/github.com/google/cadvisor/metrics/prometheus.go
generated
vendored
7
vendor/github.com/google/cadvisor/metrics/prometheus.go
generated
vendored
@@ -22,6 +22,7 @@ import (
|
||||
|
||||
"github.com/google/cadvisor/container"
|
||||
info "github.com/google/cadvisor/info/v1"
|
||||
v2 "github.com/google/cadvisor/info/v2"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"k8s.io/klog/v2"
|
||||
@@ -97,13 +98,14 @@ type PrometheusCollector struct {
|
||||
containerMetrics []containerMetric
|
||||
containerLabelsFunc ContainerLabelsFunc
|
||||
includedMetrics container.MetricSet
|
||||
opts v2.RequestOptions
|
||||
}
|
||||
|
||||
// NewPrometheusCollector returns a new PrometheusCollector. The passed
|
||||
// ContainerLabelsFunc specifies which base labels will be attached to all
|
||||
// exported metrics. If left to nil, the DefaultContainerLabels function
|
||||
// will be used instead.
|
||||
func NewPrometheusCollector(i infoProvider, f ContainerLabelsFunc, includedMetrics container.MetricSet, now clock.Clock) *PrometheusCollector {
|
||||
func NewPrometheusCollector(i infoProvider, f ContainerLabelsFunc, includedMetrics container.MetricSet, now clock.Clock, opts v2.RequestOptions) *PrometheusCollector {
|
||||
if f == nil {
|
||||
f = DefaultContainerLabels
|
||||
}
|
||||
@@ -129,6 +131,7 @@ func NewPrometheusCollector(i infoProvider, f ContainerLabelsFunc, includedMetri
|
||||
},
|
||||
},
|
||||
includedMetrics: includedMetrics,
|
||||
opts: opts,
|
||||
}
|
||||
if includedMetrics.Has(container.CpuUsageMetrics) {
|
||||
c.containerMetrics = append(c.containerMetrics, []containerMetric{
|
||||
@@ -1780,7 +1783,7 @@ func BaseContainerLabels(whiteList []string) func(container *info.ContainerInfo)
|
||||
}
|
||||
|
||||
func (c *PrometheusCollector) collectContainersInfo(ch chan<- prometheus.Metric) {
|
||||
containers, err := c.infoProvider.SubcontainersInfo("/", &info.ContainerInfoRequest{NumStats: 1})
|
||||
containers, err := c.infoProvider.GetRequestedContainersInfo("/", c.opts)
|
||||
if err != nil {
|
||||
c.errors.Set(1)
|
||||
klog.Warningf("Couldn't get containers: %s", err)
|
||||
|
15
vendor/github.com/google/cadvisor/metrics/prometheus_fake.go
generated
vendored
15
vendor/github.com/google/cadvisor/metrics/prometheus_fake.go
generated
vendored
@@ -19,6 +19,7 @@ import (
|
||||
"time"
|
||||
|
||||
info "github.com/google/cadvisor/info/v1"
|
||||
v2 "github.com/google/cadvisor/info/v2"
|
||||
)
|
||||
|
||||
type testSubcontainersInfoProvider struct{}
|
||||
@@ -264,9 +265,9 @@ func (p testSubcontainersInfoProvider) GetMachineInfo() (*info.MachineInfo, erro
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p testSubcontainersInfoProvider) SubcontainersInfo(string, *info.ContainerInfoRequest) ([]*info.ContainerInfo, error) {
|
||||
return []*info.ContainerInfo{
|
||||
{
|
||||
func (p testSubcontainersInfoProvider) GetRequestedContainersInfo(string, v2.RequestOptions) (map[string]*info.ContainerInfo, error) {
|
||||
return map[string]*info.ContainerInfo{
|
||||
"testcontainer": {
|
||||
ContainerReference: info.ContainerReference{
|
||||
Name: "testcontainer",
|
||||
Aliases: []string{"testcontaineralias"},
|
||||
@@ -710,10 +711,10 @@ func (p *erroringSubcontainersInfoProvider) GetMachineInfo() (*info.MachineInfo,
|
||||
return p.successfulProvider.GetMachineInfo()
|
||||
}
|
||||
|
||||
func (p *erroringSubcontainersInfoProvider) SubcontainersInfo(
|
||||
a string, r *info.ContainerInfoRequest) ([]*info.ContainerInfo, error) {
|
||||
func (p *erroringSubcontainersInfoProvider) GetRequestedContainersInfo(
|
||||
a string, opt v2.RequestOptions) (map[string]*info.ContainerInfo, error) {
|
||||
if p.shouldFail {
|
||||
return []*info.ContainerInfo{}, errors.New("Oops 3")
|
||||
return map[string]*info.ContainerInfo{}, errors.New("Oops 3")
|
||||
}
|
||||
return p.successfulProvider.SubcontainersInfo(a, r)
|
||||
return p.successfulProvider.GetRequestedContainersInfo(a, opt)
|
||||
}
|
||||
|
5
vendor/github.com/google/cadvisor/resctrl/manager.go
generated
vendored
5
vendor/github.com/google/cadvisor/resctrl/manager.go
generated
vendored
@@ -18,6 +18,8 @@
|
||||
package resctrl
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/google/cadvisor/stats"
|
||||
|
||||
"github.com/opencontainers/runc/libcontainer/intelrdt"
|
||||
@@ -29,6 +31,9 @@ type manager struct {
|
||||
}
|
||||
|
||||
func (m manager) GetCollector(resctrlPath string) (stats.Collector, error) {
|
||||
if _, err := os.Stat(resctrlPath); err != nil {
|
||||
return &stats.NoopCollector{}, err
|
||||
}
|
||||
collector := newCollector(m.id, resctrlPath)
|
||||
return collector, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user