attribution

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

type Index struct {
	// contains filtered or unexported fields
}

Index resolves cgroup IDs, pod UIDs and PIDs to a runtimeevent.PodIdentity.

func NewIndex

func NewIndex(log logr.Logger, opts ...Option) *Index

NewIndex returns an empty index.

func (*Index) Annotate

func (ix *Index) Annotate(ev *runtimeevent.Event) bool

Annotate fills ev.Pod from the index, trying the identities an event can carry in order of decreasing reliability: the pod uid hint a poll source pre-filled, the cgroup id both bpf engines report, then the pid of a tracepoint event. It returns false for an event no pod on this node claims, and counts the miss.

func (*Index) Len

func (ix *Index) Len() (pods int, cgroups int)

Len reports how many pods and cgroups the index holds.

func (*Index) Lookup

func (ix *Index) Lookup(cgroupID uint64) (runtimeevent.PodIdentity, bool)

Lookup resolves a cgroup inode to the owning pod and container.

func (*Index) LookupPID

func (ix *Index) LookupPID(pid uint32) (runtimeevent.PodIdentity, bool)

LookupPID resolves a PID to its pod. It first asks pkg/containers to stat the cgroup named by <procRoot>/<pid>/cgroup, which yields the inode the bpf programs key on. When that is unavailable (no cgroup mount visible, stat denied, cgroup namespaced) it falls back to the pod UID embedded in the cgroup path, which every kubelet cgroup driver writes.

func (*Index) LookupPodUID

func (ix *Index) LookupPodUID(uid string) (runtimeevent.PodIdentity, bool)

LookupPodUID resolves a pod UID to its identity. The container fields are empty, since a pod UID does not identify a container. The returned Labels map is shared with the index and must not be mutated.

func (*Index) Name

func (ix *Index) Name() string

func (*Index) PodDeleted

func (ix *Index) PodDeleted(uid string) error

PodDeleted implements events.PodEventHandler.

func (*Index) PodEvent

func (ix *Index) PodEvent(pod corev1.Pod, _ map[string]string, cgInfos []*containers.ContainerCgroupInfo, podEventType string) error

PodEvent implements events.PodEventHandler. Create and update are idempotent upserts: labels, owner and the cgroup set are recomputed from scratch and cgroups the pod has stopped owning are evicted.

func (*Index) Process

func (ix *Index) Process(ev *runtimeevent.Event) bool

func (*Index) Put

func (ix *Index) Put(cgroupID uint64, id runtimeevent.PodIdentity)

Put seeds the index directly with a pod-level identity. Exported for tests and fixture loaders; production code goes through PodEvent.

type Option

type Option func(*Index)

Option configures an Index.

func WithMetrics

func WithMetrics(m *metrics.Metrics) Option

WithMetrics wires the Prometheus collectors; without it Annotate still drops unattributable events, it just does not count them.

func WithProcRoot

func WithProcRoot(root string) Option

WithProcRoot overrides the procfs root used by LookupPID (default "/proc").

Jump to

Keyboard shortcuts

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