cgidmap

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 19 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register added in v1.8.0

func Register(src events.PodEventSource) error

Register wires cgidmap into the supplied pod event source. The caller is expected to gate this call on cgidmap being enabled, so a no-op registration when disabled does not appear in the startup log.

func SetContainerID added in v1.3.0

func SetContainerID(info *processapi.MsgK8sUnix)

Types

type CgroupID

type CgroupID = uint64

convinience types to make APIs more readable

type ContainerID

type ContainerID = string

type Map

type Map interface {
	// Get retrieves a container id based on a cgroup id
	Get(cgID CgroupID) (ContainerID, bool)

	// GetPodSandbox retrieves a pod sandbox id based on a cgroup id
	GetPodSandbox(cgID CgroupID) (PodSandboxID, bool)

	// Add adds a <podID, contID, cgroupID> entry in the mapping
	Add(podID PodID, contID ContainerID, cgroupID CgroupID)

	// AddPodSandbox adds a <podID, sandboxID, cgroupID> entry for a pod sandbox
	AddPodSandbox(podID PodID, sandboxID PodSandboxID, cgroupID CgroupID)

	// Update updates the state of pod and containers.
	// For example, previous container ids added for a certain pod will be removed if the
	// container ids are not in the provided list. Removing all information for a pod (e.g.,
	// when a pod is deleted) can be done by passing an empty list of container ids.
	Update(podID PodID, contIDs []ContainerID)

	// UpdatePodSandbox updates the state of pod sandbox.
	// If the sandboxID is different or empty, previous sandbox entries for the pod are removed.
	UpdatePodSandbox(podID PodID, sandboxID PodSandboxID)
}

Map implements the a cgroup id to container id maping

Its intended use is to associate pod information with events by using a cgroup id defined in the low-level event (bpf or proc) to find the container ID.

The idea is:

  • Get() is called by the pod-association code
  • Add() is called to update the mapping. This can happen either in runtime hooks or by talking to the CRI
  • Update() is called to update the state of container / pods. This is called by the K8s pod watcher.

func GlobalMap

func GlobalMap() (Map, error)

GlobalMap returns a global reference to the cgidmap

type PodID

type PodID = uuid.UUID

type PodSandboxID added in v1.8.0

type PodSandboxID = string

Jump to

Keyboard shortcuts

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