Documentation ¶
Index ¶
- Constants
- Variables
- func GetAvailableControllers(exclude map[string]controllerHandler, cgroup2 bool) ([]string, error)
- func GetBlkioFiles(cgroupPath string) (wtFile, wtDevFile string)
- func GetSystemCPUUsage() (uint64, error)
- func GetUserConnection(uid int) (*systemdDbus.Conn, error)
- func IsCgroup2UnifiedMode() (bool, error)
- func OpenFile(dir, file string, flags int) (*os.File, error)
- func ReadFile(dir, file string) (string, error)
- func SetBlkioThrottle(res *configs.Resources, cgroupPath string) error
- func UserOwnsCurrentSystemdCgroup() (bool, error)
- func WriteFile(dir, file, data string) error
- type BlkioDev
- type CgroupControl
- func (c *CgroupControl) AddPid(pid int) error
- func (c *CgroupControl) CreateSystemdUnit(path string) error
- func (c *CgroupControl) CreateSystemdUserUnit(path string, uid int) error
- func (c *CgroupControl) Delete() error
- func (c *CgroupControl) DeleteByPath(path string) error
- func (c *CgroupControl) DeleteByPathConn(path string, conn *systemdDbus.Conn) error
- func (c *CgroupControl) Stat() (*cgroups.Stats, error)
- func (c *CgroupControl) Update(resources *configs.Resources) error
Constants ¶
const ( // CPU is the cpu controller CPU = "cpu" // CPUAcct is the cpuacct controller CPUAcct = "cpuacct" // CPUset is the cpuset controller CPUset = "cpuset" // Memory is the memory controller Memory = "memory" // Pids is the pids controller Pids = "pids" // Blkio is the blkio controller Blkio = "blkio" )
Variables ¶
var ( // ErrCgroupDeleted means the cgroup was deleted ErrCgroupDeleted = errors.New("cgroup deleted") // ErrCgroupV1Rootless means the cgroup v1 were attempted to be used in rootless environment ErrCgroupV1Rootless = errors.New("no support for CGroups V1 in rootless environments") ErrStatCgroup = errors.New("no cgroup available for gathering user statistics") )
var TestMode bool
Functions ¶
func GetAvailableControllers ¶ added in v0.47.0
GetAvailableControllers get string:bool map of all the available controllers
func GetBlkioFiles ¶ added in v0.49.0
GetBlkioFiles gets the proper files for blkio weights
func GetSystemCPUUsage ¶ added in v0.47.0
GetSystemCPUUsage returns the system usage for all the cgroups
func GetUserConnection ¶
func GetUserConnection(uid int) (*systemdDbus.Conn, error)
GetUserConnection returns an user connection to D-BUS
func IsCgroup2UnifiedMode ¶
IsCgroup2UnifiedMode returns whether we are running in cgroup 2 cgroup2 mode.
func ReadFile ¶ added in v0.49.0
ReadFile reads from a cgroup file, opening it with the read only flag
func SetBlkioThrottle ¶ added in v0.49.0
SetBlkioThrottle sets the throttle limits for the cgroup
func UserOwnsCurrentSystemdCgroup ¶
UserOwnsCurrentSystemdCgroup checks whether the current EUID owns the current cgroup.
Types ¶
type CgroupControl ¶
type CgroupControl struct {
// contains filtered or unexported fields
}
CgroupControl controls a cgroup hierarchy
func New ¶
func New(path string, resources *configs.Resources) (*CgroupControl, error)
New creates a new cgroup control
func NewSystemd ¶
func NewSystemd(path string, resources *configs.Resources) (*CgroupControl, error)
NewSystemd creates a new cgroup control
func (*CgroupControl) AddPid ¶
func (c *CgroupControl) AddPid(pid int) error
AddPid moves the specified pid to the cgroup
func (*CgroupControl) CreateSystemdUnit ¶
func (c *CgroupControl) CreateSystemdUnit(path string) error
CreateSystemdUnit creates the systemd cgroup
func (*CgroupControl) CreateSystemdUserUnit ¶
func (c *CgroupControl) CreateSystemdUserUnit(path string, uid int) error
CreateSystemdUserUnit creates the systemd cgroup for the specified user
func (*CgroupControl) DeleteByPath ¶
func (c *CgroupControl) DeleteByPath(path string) error
DeleteByPath deletes the specified cgroup path
func (*CgroupControl) DeleteByPathConn ¶
func (c *CgroupControl) DeleteByPathConn(path string, conn *systemdDbus.Conn) error
DeleteByPathConn deletes the specified cgroup path using the specified dbus connection if needed.