containment

package
v1.10.4 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package containment binds workers and payloads to one job service cgroup.

Index

Constants

View Source
const WorkerUnitPattern = workerUnitPrefix + "*.service"

WorkerUnitPattern selects only the host-reserved worker instance namespace.

Variables

View Source
var (
	// ErrAbsent reports an absent service cgroup, not a fence against future starts.
	ErrAbsent = errors.New("cortex: sandbox service cgroup absent")
	// ErrChanged reports a cgroup appearing after an absent kill target.
	ErrChanged = errors.New("cortex: sandbox containment changed during cleanup")
)

Functions

func CheckMembership

func CheckMembership(key id.ID, body []byte) error

CheckMembership verifies the exact cgroup-v2 worker subgroup. A payload, sibling job, descendant subgroup or legacy hierarchy is not equivalent.

func JobFromUnit

func JobFromUnit(unit string) (id.ID, error)

JobFromUnit accepts only the canonical service name generated by ForJob. Aliases, paths and identities belonging to other entity types are refused.

func VerifyCurrent

func VerifyCurrent(ctx context.Context, key id.ID) error

VerifyCurrent requires a root worker in the exact delegated service subgroup. The procfs and cgroup-v2 mounts are checked before any runtime invocation.

func VerifyReaper

func VerifyReaper(ctx context.Context, key id.ID) error

VerifyReaper refuses containment operations from inside the target hierarchy.

Types

type Layout

type Layout struct{ Unit, Parent, Worker, Payload string }

Layout is the fixed service hierarchy. The service manager must delegate controllers and place its worker in supervisor; runsc creates payload below the same parent. The outer service's kill policy must cover every descendant.

func ForJob

func ForJob(key id.ID) (Layout, error)

ForJob never accepts a caller-selected service or cgroup path.

type Observation

type Observation struct{ Empty, Absent bool }

Observation distinguishes an empty hierarchy from an absent hierarchy. Neither proves that the service manager cannot launch a queued worker later. Establish a durable start fence separately before recording workerstore.Reaped.

func KillAndWait

func KillAndWait(ctx context.Context, key id.ID) (Observation, error)

KillAndWait uses cgroup.kill and waits for the complete hierarchy to empty. It requires a root-run Linux reaper outside the target group. Supply an independent cleanup context; waits are capped at ten seconds. No PID walk, process-group fallback or cgroup deletion is performed.

Jump to

Keyboard shortcuts

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