ateomcgroup

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package ateomcgroup delegates the worker pod's cgroup to the ateom so each actor can get a leaf of its own.

Index

Constants

View Source
const Root = "/sys/fs/cgroup"

Root is the worker pod's cgroup scope inside its private cgroup namespace.

Variables

This section is empty.

Functions

func Delegate

func Delegate(ctx context.Context) (bool, error)

Delegate prepares the worker pod's cgroup so the runtime can create per-actor leaves under it with real cpu/memory/pids accounting. It reports whether it did: a worker outside a private cgroup namespace is left alone.

The unprivileged worker runs in a private cgroup namespace, so /sys/fs/cgroup is the pod's own cgroup scope rather than the host root. Two things must be arranged before runsc can nest container cgroups here:

  • The cgroup v2 "no internal processes" rule forbids a cgroup from holding processes directly while also delegating controllers to children. The pod scope is not the true cgroup root, so the exemption does not apply: we move the worker's own processes into a dedicated "ateom" leaf.
  • Controllers are only available to children if enabled in the scope's cgroup.subtree_control. We enable everything the parent delegated to us.

The runtime bind-mounts /sys/fs/cgroup read-only for unprivileged pods. The worker holds CAP_SYS_ADMIN with no user namespace, so the ro flag is not locked: clear it and leave it writable (the runtime writes here on every create/restore).

func KillActorLeaf

func KillActorLeaf(ctx context.Context, name string) error

KillActorLeaf kills every process in the named leaf, including any they forked, and waits until the leaf is empty or ctx is done. A missing leaf, or a kernel without cgroup.kill, has nothing done.

func KillLeafUnder

func KillLeafUnder(ctx context.Context, root, name string) error

KillLeafUnder is KillActorLeaf for a leaf under root rather than Root.

func RemoveActorLeaf

func RemoveActorLeaf(actorUID string) error

RemoveActorLeaf deletes the actor's leaf. Its processes must have exited.

Types

type ActorLeaf

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

ActorLeaf is a cgroup of its own for one actor's host processes, so actors on one worker share its CPU fairly and each stays within its declared limit.

func OpenActorLeaf

func OpenActorLeaf(actorUID string, milliCPU int64) (*ActorLeaf, error)

OpenActorLeaf creates the actor's leaf under the delegated scope, or reuses a leftover one, and caps it at milliCPU when that is set. Close it once its processes are started.

func (*ActorLeaf) Close

func (l *ActorLeaf) Close() error

Close releases the leaf's handle. The leaf itself stays until RemoveActorLeaf.

func (*ActorLeaf) SysProcAttr

func (l *ActorLeaf) SysProcAttr() *syscall.SysProcAttr

SysProcAttr starts a process directly inside the leaf. A nil leaf starts it where the caller is.

Jump to

Keyboard shortcuts

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