Version: v0.0.0-...-8223eb1 Latest Latest

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

Go to latest
Published: Jan 14, 2020 License: Apache-2.0 Imports: 9 Imported by: 0




View Source
const (
	CPUPeriod = 1000000 // 1 million microseconds which equals 1 second


View Source
var DefaultSubsystemer = &ProcSubsystemer{}
View Source
var DefaultSubsystems = Subsystems{
	CPU:    "/cgroup/cpu",
	Memory: "/cgroup/memory",
	Prefix: "/cgroup",


func CreatePodCgroup

func CreatePodCgroup(podID types.PodID, hostname types.NodeName, c Config, s Subsystemer) error

CreatePodCgroup will set cgroup parameters for the specified pod with podID on hostname. In order for nested cgroups to work correctly, the path used here must match the path used in pkg/servicebuilder


type CgroupID

type CgroupID string

func CgroupIDForLaunchable

func CgroupIDForLaunchable(s Subsystemer, podID types.PodID, nodeName types.NodeName, launchableID string) (*CgroupID, error)

CgroupIDForLaunchable encapsulates the cgroup path for launchable cgroups. launchableID is a string because I am too cowardly to break the import cycle caused by importing `launch` here.

func CgroupIDForPod

func CgroupIDForPod(s Subsystemer, podID types.PodID, nodeName types.NodeName) (*CgroupID, error)

CgroupIDForPod encapsulates the cgroup path for pod cgroups. This function should match CgroupIDForLaunchable

func (*CgroupID) String

func (c *CgroupID) String() string

type Config

type Config struct {
	Name   CgroupID       `yaml:"-"`                // The name of the cgroup in cgroupfs
	CPUs   int            `yaml:"cpus,omitempty"`   // The number of logical CPUs
	Memory size.ByteCount `yaml:"memory,omitempty"` // The number of bytes of memory

Config combines an ID and subsystem limits

type ProcSubsystemer

type ProcSubsystemer struct {
	CachedSubsystems *Subsystems

ProcSubsystemer returns cgroup mountpoints based on the /proc filesystem

func (*ProcSubsystemer) Find

func (ps *ProcSubsystemer) Find() (Subsystems, error)

type Subsystemer

type Subsystemer interface {
	Find() (Subsystems, error)

Subsystemer is anything that can find a set of Subsystems

type Subsystems

type Subsystems struct {
	CPU    string
	Memory string
	Prefix string

maps cgroup subsystems to their respective paths

func (Subsystems) AddPID

func (subsys Subsystems) AddPID(name string, pid int) error

func (Subsystems) SetCPU

func (subsys Subsystems) SetCPU(name CgroupID, cpus int) error

SetCPU will set a number of CPU limits in the cgroup specified by the argument. A sentinel value of 0 will create an unrestricted CPU subsystem

func (Subsystems) SetMemory

func (subsys Subsystems) SetMemory(name CgroupID, bytes int) error

SetMemory will set several memory limits in the cgroup specified in the argument. A sentinel value of 0 will create an unrestricted memory subsystem

func (Subsystems) Write

func (subsys Subsystems) Write(config Config) error

type UnsupportedError

type UnsupportedError string

func (UnsupportedError) Error

func (err UnsupportedError) Error() string

Jump to

Keyboard shortcuts

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