2019-01-12 04:58:27 +00:00
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package cgroups
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/opencontainers/runc/libcontainer/configs"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Manager interface {
|
2021-06-18 20:46:09 +00:00
|
|
|
// Apply creates a cgroup, if not yet created, and adds a process
|
|
|
|
// with the specified pid into that cgroup. A special value of -1
|
|
|
|
// can be used to merely create a cgroup.
|
2019-01-12 04:58:27 +00:00
|
|
|
Apply(pid int) error
|
|
|
|
|
2021-06-18 20:46:09 +00:00
|
|
|
// GetPids returns the PIDs of all processes inside the cgroup.
|
2019-01-12 04:58:27 +00:00
|
|
|
GetPids() ([]int, error)
|
|
|
|
|
2021-06-18 20:46:09 +00:00
|
|
|
// GetAllPids returns the PIDs of all processes inside the cgroup
|
|
|
|
// any all its sub-cgroups.
|
2019-01-12 04:58:27 +00:00
|
|
|
GetAllPids() ([]int, error)
|
|
|
|
|
2021-06-18 20:46:09 +00:00
|
|
|
// GetStats returns cgroups statistics.
|
2019-01-12 04:58:27 +00:00
|
|
|
GetStats() (*Stats, error)
|
|
|
|
|
2021-06-18 20:46:09 +00:00
|
|
|
// Freeze sets the freezer cgroup to the specified state.
|
2019-01-12 04:58:27 +00:00
|
|
|
Freeze(state configs.FreezerState) error
|
|
|
|
|
2021-06-18 20:46:09 +00:00
|
|
|
// Destroy removes cgroup.
|
2019-01-12 04:58:27 +00:00
|
|
|
Destroy() error
|
|
|
|
|
2020-08-10 17:43:49 +00:00
|
|
|
// Path returns a cgroup path to the specified controller/subsystem.
|
|
|
|
// For cgroupv2, the argument is unused and can be empty.
|
|
|
|
Path(string) string
|
2020-05-04 20:46:48 +00:00
|
|
|
|
2021-06-18 20:46:09 +00:00
|
|
|
// Set sets cgroup resources parameters/limits. If the argument is nil,
|
|
|
|
// the resources specified during Manager creation (or the previous call
|
|
|
|
// to Set) are used.
|
|
|
|
Set(r *configs.Resources) error
|
2020-05-04 20:46:48 +00:00
|
|
|
|
2021-06-18 20:46:09 +00:00
|
|
|
// GetPaths returns cgroup path(s) to save in a state file in order to
|
|
|
|
// restore later.
|
2020-08-10 17:43:49 +00:00
|
|
|
//
|
2021-06-18 20:46:09 +00:00
|
|
|
// For cgroup v1, a key is cgroup subsystem name, and the value is the
|
|
|
|
// path to the cgroup for this subsystem.
|
2020-08-10 17:43:49 +00:00
|
|
|
//
|
2021-06-18 20:46:09 +00:00
|
|
|
// For cgroup v2 unified hierarchy, a key is "", and the value is the
|
|
|
|
// unified path.
|
2020-08-10 17:43:49 +00:00
|
|
|
GetPaths() map[string]string
|
2019-01-12 04:58:27 +00:00
|
|
|
|
2020-08-10 17:43:49 +00:00
|
|
|
// GetCgroups returns the cgroup data as configured.
|
|
|
|
GetCgroups() (*configs.Cgroup, error)
|
2019-01-12 04:58:27 +00:00
|
|
|
|
2020-08-10 17:43:49 +00:00
|
|
|
// GetFreezerState retrieves the current FreezerState of the cgroup.
|
|
|
|
GetFreezerState() (configs.FreezerState, error)
|
2019-01-12 04:58:27 +00:00
|
|
|
|
2021-06-18 20:46:09 +00:00
|
|
|
// Exists returns whether the cgroup path exists or not.
|
2020-08-10 17:43:49 +00:00
|
|
|
Exists() bool
|
2021-04-14 18:11:13 +00:00
|
|
|
|
|
|
|
// OOMKillCount reports OOM kill count for the cgroup.
|
|
|
|
OOMKillCount() (uint64, error)
|
2019-01-12 04:58:27 +00:00
|
|
|
}
|