Skip to main content

CgroupV2

Struct CgroupV2 

Source
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

Source

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.

Source

fn new(leaf: &Path) -> Self

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

fn subscribe(&self) -> Result<Subscriptions>

Watch the memory events of the container and, if present, the ones of the outer cgroup.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more