containers

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package containers resolves the cgroup identity (path + inode) of a pod's containers. The cgroup inode is the key both BPF engines use to attribute kernel events back to a workload, so nothing in this package may panic on a pod object, a mountinfo line, or a procfs file.

Index

Constants

View Source
const DefaultProcRoot = "/proc"

DefaultProcRoot is the procfs root used by the exported helpers that do not take one explicitly. Tests always pass their own fake tree.

Variables

This section is empty.

Functions

func ExtractCgPaths

func ExtractCgPaths(cgInfos []*ContainerCgroupInfo) []string

func ExtractCgids

func ExtractCgids(cgInfos []*ContainerCgroupInfo) []uint64

Types

type ContainerCgroupInfo

type ContainerCgroupInfo struct {
	ID   uint64
	Path string
	Name string // container name, needed by attribution
}

ContainerCgroupInfo is the resolved cgroup identity of a single container. It is used as a map key by the managers, so every field must stay comparable.

func ResolveCgInfos

func ResolveCgInfos(pod *corev1.Pod) ([]*ContainerCgroupInfo, error)

ResolveCgInfos resolves the cgroup identity of every running container of pod. It never panics and never lets a single unresolvable container discard its healthy siblings: containers whose ID is missing (not started yet) or whose cgroup path cannot be found are skipped, and the infos that could be resolved are returned together with a joined error describing the rest, so callers may retry later.

func ResolveCgroupByPID

func ResolveCgroupByPID(procRoot string, pid uint32) (*ContainerCgroupInfo, error)

ResolveCgroupByPID is the authoritative fallback: it asks the kernel which cgroup a pid belongs to instead of guessing a layout. The daemon runs with hostPID and mounts /, so this works for every runtime, cgroup driver and cgroup version. procRoot is parameterized for tests.

Jump to

Keyboard shortcuts

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