Documentation
¶
Index ¶
- type Index
- func (ix *Index) Annotate(ev *runtimeevent.Event) bool
- func (ix *Index) Len() (pods int, cgroups int)
- func (ix *Index) Lookup(cgroupID uint64) (runtimeevent.PodIdentity, bool)
- func (ix *Index) LookupPID(pid uint32) (runtimeevent.PodIdentity, bool)
- func (ix *Index) LookupPodUID(uid string) (runtimeevent.PodIdentity, bool)
- func (ix *Index) Name() string
- func (ix *Index) PodDeleted(uid string) error
- func (ix *Index) PodEvent(pod corev1.Pod, _ map[string]string, cgInfos []*containers.ContainerCgroupInfo, ...) error
- func (ix *Index) Process(ev *runtimeevent.Event) bool
- func (ix *Index) Put(cgroupID uint64, id runtimeevent.PodIdentity)
- type Option
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 (*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) 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) PodDeleted ¶
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) 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 ¶
WithMetrics wires the Prometheus collectors; without it Annotate still drops unattributable events, it just does not count them.
func WithProcRoot ¶
WithProcRoot overrides the procfs root used by LookupPID (default "/proc").