Documentation
¶
Index ¶
- Constants
- func CreateTransient(cgroupRoot, name string) (path string, id uint64, cleanup func() error, err error)
- func FindContainerCgroupPath(cgroupRoot, podUID, containerID string) (string, error)
- func GetCgroupInodeFromPath(path string) (uint64, error)
- func ReadCgroupProcs(cgroupPath string) ([]int, error)
Constants ¶
const DefaultCgroupRoot = "/sys/fs/cgroup"
DefaultCgroupRoot is the standard cgroup v2 root
const KloakSliceName = "kloak.slice"
KloakSliceName is the directory under the cgroup root where every `kloak run` invocation creates its transient cgroup. The `.slice` suffix is a courtesy to systemd-managed hosts (so a top-level kloak.slice can be hand-delegated if needed); on a pure cgroup v2 system it's just a regular directory.
Variables ¶
This section is empty.
Functions ¶
func CreateTransient ¶ added in v0.2.0
func CreateTransient(cgroupRoot, name string) (path string, id uint64, cleanup func() error, err error)
CreateTransient mkdirs a fresh cgroup at <cgroupRoot>/<KloakSliceName>/<name> and returns its path, inode ID, and a cleanup function.
The KloakSliceName parent is created on demand and is intentionally NOT removed by the cleanup function — multiple concurrent `kloak run` invocations share that parent, and Phase 4 will handle a startup sweep for orphans.
`name` must be a non-empty single path component (no `/`, no `..`). Callers typically pass a UUID. We validate explicitly rather than leaning on filepath.Join's normalization so a malicious name fails loudly instead of escaping the slice parent.
The cleanup function is idempotent: calling it after the cgroup is already gone returns nil. It only errors when the cgroup is non-empty (e.g. a child process is still alive in `cgroup.procs`) — at which point the runtime's signal handler is expected to have killed the survivors first.
Errors from the initial mkdir (read-only cgroupfs, permission denied, …) are wrapped with the candidate path so the operator can fix the host without spelunking through syscall errors.
func FindContainerCgroupPath ¶
FindContainerCgroupPath attempts to find the cgroup path for a container ID. Tries well-known patterns first, then falls back to walking the cgroup tree.
func GetCgroupInodeFromPath ¶
GetCgroupInodeFromPath returns the inode number of a cgroup directory on Linux.
func ReadCgroupProcs ¶
ReadCgroupProcs reads the PIDs from a cgroup's cgroup.procs file.
Types ¶
This section is empty.