manager

package
v0.60.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Manager of cAdvisor-monitored containers.

Index

Constants

View Source
const (
	DockerNamespace = "docker"
	PodmanNamespace = "podman"
)

The namespace under which aliases are unique.

Variables

View Source
var (
	// PerfManagerFactory builds the perf_event stats manager. Set by the root
	// binary to perf.NewManager.
	PerfManagerFactory func(configFile string, topology []info.Node) (stats.Manager, error)

	// ResctrlManagerFactory builds the resctrl stats manager. Set by the root
	// binary to resctrl.NewManager.
	ResctrlManagerFactory func(interval time.Duration, vendorID string, inHostNamespace bool) (stats.ResctrlManager, error)
)

Collector-manager injection seam.

The kubelet-only library does not import the perf_event / resctrl implementations (or their dependencies). Instead, the full cAdvisor binary registers factories here at init time; when a factory is nil (the kubelet case) the manager falls back to a Noop manager, so no stats are collected for that controller. This keeps github.com/google/cadvisor/lib lean while letting the binary remain fully functional.

View Source
var CollectorManagerFactory func(handler container.ContainerHandler, readFile func(string) ([]byte, error)) (CollectorManager, error)

CollectorManagerFactory builds a per-container collector manager. It receives the container handler (to discover collector configs from its labels) and a readFile func (to read those config files from inside the container). Set by the root binary.

View Source
var CpuLoadReaderFactory func() (CpuLoadReader, error)

CpuLoadReaderFactory builds a CpuLoadReader. Set by the root binary when --enable_load_reader is on; nil for the kubelet.

View Source
var HousekeepingConfigFlags = HousekeepingConfig{
	flag.Duration("max_housekeeping_interval", 60*time.Second, "Largest interval to allow between container housekeepings"),
	flag.Bool("allow_dynamic_housekeeping", true, "Whether to allow the housekeeping interval to be dynamic"),
}
View Source
var HousekeepingInterval = flag.Duration("housekeeping_interval", 1*time.Second, "Interval between container housekeepings")
View Source
var InitialSplayFactor = flag.Float64("initial_splay_factor", jitterDefault, "Factor for the initial splay b/w the container housekeepings, default is 1.0. If negative value is passed, the value will be reset to default")
View Source
var JitterFactor = flag.Float64("jitter_factor", jitterDefault, "Factor for the jitters after the initial splay b/w the container housekeepings, default is 1.0. If negative value is passed, the value will be reset to default")
View Source
var ProcessListProvider func(containerName string, isRoot bool, cadvisorContainer string, inHostNamespace bool) ([]info.ProcessInfo, error)

ProcessListProvider lists the processes running in a container (the v2 /ps endpoint). containerName is the container's cgroup name; isRoot reports whether it is the root container. Set by the root binary to a ps-based implementation; nil for the kubelet (GetProcessList returns empty).

View Source
var SummaryReaderFactory func(spec info.ContainerSpec) (SummaryReader, error)

SummaryReaderFactory builds a per-container summary reader from its spec. Set by the root binary (wrapping summary.New).

Functions

func ApplicationMetricsCountLimit

func ApplicationMetricsCountLimit() int

ApplicationMetricsCountLimit exposes the application_metrics_count_limit flag value so the root binary can build its collectors without re-registering the flag.

func EventStorageAgeLimit

func EventStorageAgeLimit() string

EventStorageAgeLimit and EventStorageEventLimit expose the values of the event_storage_* flags this package registers (for kubelet flag-compatibility) so the root binary can build its events storage policy without re-registering — and double-registering — the same flags.

func EventStorageEventLimit

func EventStorageEventLimit() string

Types

type CollectorManager

type CollectorManager interface {
	Collect() (time.Time, map[string][]info.MetricVal, error)
	GetSpec() ([]info.MetricSpec, error)
}

CollectorManager runs application-metrics collectors for one container and aggregates their custom metrics. The full binary injects a manager backed by the collector package; the kubelet leaves CollectorManagerFactory nil (no custom metrics).

type CpuLoadReader

type CpuLoadReader interface {
	Start() error
	Stop()
	GetCpuLoad(name string, path string) (info.LoadStats, error)
}

CpuLoadReader reads per-container CPU load over netlink (runnable/uninterruptible task counts). The implementation lives in the root binary's utils/cpuload (CAP_NET_ADMIN, a persistent netlink connection); the kubelet leaves CpuLoadReaderFactory nil so no reader is created and LoadAverage stays zero.

type EventSink

type EventSink interface {
	AddEvent(*info.Event) error
}

EventSink receives the container lifecycle (creation/deletion) and OOM events the manager emits. The full cAdvisor binary injects its events.EventManager here (it satisfies this interface) and serves them over the /events REST API; the kubelet leaves it nil, so the manager emits nothing and the library carries no event-storage machinery. This is the same injection pattern as the perf/resctrl factories — see plugins.go.

type HousekeepingConfig

type HousekeepingConfig = struct {
	Interval     *time.Duration
	AllowDynamic *bool
}

Housekeeping configuration for the manager

type Manager

type Manager interface {
	// Start the manager. Calling other manager methods before this returns
	// may produce undefined behavior.
	Start() error

	// Stops the manager.
	Stop() error

	// Get V2 information about a container.
	// Recursive (subcontainer) requests are best-effort, and may return a partial result alongside an
	// error in the partial failure case.
	GetContainerInfoV2(containerName string, options info.RequestOptions) (map[string]info.ContainerInfo, error)

	// Get info for all requested containers based on the request options.
	GetRequestedContainersInfo(containerName string, options info.RequestOptions) (map[string]*info.ContainerInfo, error)

	// Get information about the machine.
	GetMachineInfo() (*info.MachineInfo, error)

	// Get version information about different components we depend on.
	GetVersionInfo() (*info.VersionInfo, error)

	// Get filesystem information for the filesystem that contains the given directory
	GetDirFsInfo(dir string) (info.FsInfo, error)

	// Get filesystem information for a given label.
	// Returns information for all global filesystems if label is empty.
	GetFsInfo(label string) ([]info.FsInfo, error)

	// DebugInfo returns debug information about the manager's tracked containers.
	DebugInfo() map[string][]string

	// Get information about a container.
	GetContainerInfo(containerName string, query *info.ContainerInfoRequest) (*info.ContainerInfo, error)

	// Get information about all subcontainers of the specified container (includes self).
	SubcontainersInfo(containerName string, query *info.ContainerInfoRequest) ([]*info.ContainerInfo, error)

	// Get information about the docker containers (by container name) of an instance.
	AllDockerContainers(query *info.ContainerInfoRequest) (map[string]info.ContainerInfo, error)

	// Get information about the docker container with the specified name.
	DockerContainer(dockerName string, query *info.ContainerInfoRequest) (info.ContainerInfo, error)

	// Get information about the podman containers (by container name) of an instance.
	AllPodmanContainers(query *info.ContainerInfoRequest) (map[string]info.ContainerInfo, error)

	// Get information about the podman container with the specified name.
	PodmanContainer(containerName string, query *info.ContainerInfoRequest) (info.ContainerInfo, error)

	// Get the specs for a container, possibly with subcontainers.
	GetContainerSpec(containerName string, options info.RequestOptions) (map[string]info.ContainerSpec, error)

	// Get filesystem information for the filesystem identified by the given UUID.
	GetFsInfoByFsUUID(uuid string) (info.FsInfo, error)

	// Returns true if the named container exists.
	Exists(containerName string) bool

	// Get the derived (rolling-window percentile) stats for a container.
	GetDerivedStats(containerName string, options info.RequestOptions) (map[string]info.DerivedStats, error)

	// Get the list of processes running in a container.
	GetProcessList(containerName string, options info.RequestOptions) ([]info.ProcessInfo, error)

	// SetEventSink wires the sink that receives container lifecycle and OOM
	// events. The full binary injects its events manager; the kubelet does not
	// call this (no events are emitted). See events.go.
	SetEventSink(sink EventSink)
}

The Manager interface defines operations for starting a manager and getting container and machine information.

func New

func New(memoryCache *memory.InMemoryCache, sysfs sysfs.SysFs, HousekeepingConfig HousekeepingConfig, includedMetricsSet container.MetricSet, rawContainerCgroupPathPrefixWhiteList, containerEnvMetadataWhiteList []string, perfEventsFile string, resctrlInterval time.Duration) (Manager, error)

New takes a memory storage and returns a new manager.

type SummaryReader

type SummaryReader interface {
	AddSample(stat info.ContainerStats) error
	DerivedStats() (info.DerivedStats, error)
}

SummaryReader computes rolling-window derived/percentile usage stats for a single container. The full binary injects a reader backed by the summary package; the kubelet leaves SummaryReaderFactory nil and no derived stats are produced (GetDerivedStats reports "not enabled").

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL