struct CgroupV2 {
events: MemoryEvents,
outer: Option<(PathBuf, OomCounters)>,
}Expand description
The memory events of a cgroup v2 leaf and of the cgroups above it.
crun places the process in a leaf below the container cgroup and applies the memory limit to both. The kill is always counted in the victim’s own cgroup, the leaf, so it tells about an OOM which the limit of the cgroup wrapping it caused as well.
Fields§
§events: MemoryEvents§outer: Option<(PathBuf, OomCounters)>The hierarchical memory events of the pod cgroup, which outlives a leaf the systemd cgroup manager removes, or without one of the nearest ancestor which is no scope, and the OOM counters which the leaf does not account for. They advance while the leaf exists, so that only kills after its removal stay ambiguous.
Implementations§
Source§impl CgroupV2
impl CgroupV2
Sourceconst POD_LEVELS: usize = 2
const POD_LEVELS: usize = 2
How many levels above the leaf the pod cgroup may be: its parent with runc, its grandparent with crun, which adds a leaf below the container cgroup.
fn new(leaf: &Path) -> Self
Sourcefn is_outer_event(&self, event: &WatchEvent) -> bool
fn is_outer_event(&self, event: &WatchEvent) -> bool
Whether a watch event concerns the outer cgroup. Events which the kernel dropped may have, the baseline gets read again then.
Sourcefn pod_cgroup(leaf: &Path) -> Option<&Path>
fn pod_cgroup(leaf: &Path) -> Option<&Path>
The pod cgroup above the leaf, if there is one within
CgroupV2::POD_LEVELS. Further up, like in a QoS cgroup, the
siblings are other pods.
Sourcefn outliving_ancestor(leaf: &Path) -> Option<&Path>
fn outliving_ancestor(leaf: &Path) -> Option<&Path>
The nearest ancestor which systemd does not remove together with the
leaf: the parent, unless the leaf is the one crun creates below the
scope of the container (<parent>/crio-<id>.scope/container).
Sourcefn is_pod_cgroup_name(name: &str) -> bool
fn is_pod_cgroup_name(name: &str) -> bool
Whether the name is the one the kubelet gives to a pod cgroup, like
pod<uid> with the cgroupfs driver and
kubepods-burstable-pod<uid>.slice with the systemd one.
Sourcefn check(&mut self, outer_changed: bool) -> bool
fn check(&mut self, outer_changed: bool) -> bool
Whether the counters of the leaf went up. After an event of the outer cgroup, its kills since the last check stem from a sibling otherwise, as long as the leaf still exists. The kernel counts a kill in the leaf before its ancestors, so the outer cgroup gets read first.
Sourcefn check_on_exit(&mut self) -> OOMEvent
fn check_on_exit(&mut self) -> OOMEvent
Check for an OOM a last time once the process exited. If the leaf is gone, a kill of the outer cgroup since tells that it may have been one, and so does an outer cgroup which is gone as well. A leaf which exists without memory events has no memory controller, its kills count in the outer cgroup, but without outer counters nothing tells of an OOM.
For such a leaf, the outer counters include the kills of siblings over the whole life of the leaf, the baseline only advances while the leaf has memory events, so an OOM of a sibling may still read as one of this container for an exit with 137.
Sourcefn subscribe(&self) -> Result<Subscriptions>
fn subscribe(&self) -> Result<Subscriptions>
Watch the memory events of the container and, if present, the ones of the outer cgroup.
Auto Trait Implementations§
impl Freeze for CgroupV2
impl RefUnwindSafe for CgroupV2
impl Send for CgroupV2
impl Sync for CgroupV2
impl Unpin for CgroupV2
impl UnsafeUnpin for CgroupV2
impl UnwindSafe for CgroupV2
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].