Help us shape the future of Go! Take the 2026 Go Developer Survey

cgroups

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package cgroups provides cgroup management for containers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	CPUPeriod        uint64
	CPUQuota         int64
	CPUShares        uint64
	CpusetCpus       string
	CpusetMems       string
	Memory           int64
	MemorySwap       int64
	MemorySwappiness *uint64
	PidsLimit        int64
	BlkioWeight      uint16
	NanoCpus         int64
	OomKillDisable   bool
}

Config holds cgroup configuration.

type Manager

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

Manager manages cgroups v2 for containers.

func NewManager

func NewManager(root string) *Manager

NewManager creates a new cgroup manager.

func (*Manager) AddProcess

func (m *Manager) AddProcess(containerID string, pid int) error

AddProcess adds a process to the cgroup.

func (*Manager) CgroupPath added in v0.12.0

func (m *Manager) CgroupPath(containerID string) string

CgroupPath returns the absolute cgroup v2 path for a container.

func (*Manager) Create

func (m *Manager) Create(containerID string, cfg *Config) (string, error)

Create creates a cgroup for a container.

func (*Manager) Destroy

func (m *Manager) Destroy(containerID string) error

Destroy removes the cgroup for a container.

func (*Manager) Freeze

func (m *Manager) Freeze(containerID string) error

Freeze pauses a container by moving it to a frozen cgroup.

func (*Manager) GetStats

func (m *Manager) GetStats(containerID string) (map[string]interface{}, error)

GetStats returns cgroup statistics for a container.

func (*Manager) GetStatsFull added in v0.12.0

func (m *Manager) GetStatsFull(containerID string) (map[string]interface{}, error)

GetStatsFull returns full cgroup statistics for a container, including PSI for cpu/memory/io.

func (*Manager) IsAvailable

func (m *Manager) IsAvailable() bool

IsAvailable checks if cgroups v2 is available.

func (*Manager) KillAll

func (m *Manager) KillAll(containerID string) error

KillAll sends a signal to all processes in the cgroup.

func (*Manager) Pressure added in v0.12.0

func (m *Manager) Pressure(containerID, file string) (PSIStats, error)

Pressure reads a cgroup v2 pressure file (e.g. cpu.pressure).

func (*Manager) Thaw

func (m *Manager) Thaw(containerID string) error

Thaw resumes a paused container.

func (*Manager) Update added in v0.12.0

func (m *Manager) Update(containerID string, cfg *Config) error

Update atomically updates a subset of cgroup limits. Implements CRI UpdateContainerResources semantics: rollback on any failure.

Returns the per-controller set of errors so the caller can surface them in CRI/ContainerStats. The bool indicates whether at least one resource was updated.

type PSIStats added in v0.12.0

type PSIStats struct {
	Some float64 `json:"some"`
	Full float64 `json:"full"`
}

PSIStats holds cgroup v2 pressure-stall information.

Jump to

Keyboard shortcuts

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