resourcecontrol

package
v0.0.0-...-e5e0983 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// prepend a kata specific string to oci cgroup path to
	// form a different cgroup path, thus cAdvisor couldn't
	// find kata containers cgroup path on host to prevent it
	// from grabbing the stats data.
	CgroupKataPrefix = "kata"
)
View Source
const DefaultResourceControllerID = "/vc"

DefaultResourceControllerID runtime-determined location in the cgroups hierarchy.

Variables

View Source
var (
	ErrCgroupMode = errors.New("cgroup controller type error")
)

Functions

func DeviceToCgroupDeviceRule

func DeviceToCgroupDeviceRule(device string) (*devices.Rule, error)

func DeviceToLinuxDevice

func DeviceToLinuxDevice(device string) (specs.LinuxDeviceCgroup, error)

func IsCgroupV1

func IsCgroupV1() (bool, error)

func IsSystemdCgroup

func IsSystemdCgroup(cgroupPath string) bool

func RenameCgroupPath

func RenameCgroupPath(path string) (string, error)

func SetLogger

func SetLogger(logger *logrus.Entry)

SetLogger sets up a logger for this pkg

func SetThreadAffinity

func SetThreadAffinity(threadID int, cpuSetSlice []int) error

func ValidCgroupPath

func ValidCgroupPath(path string, isCgroupV2 bool, systemdCgroup bool) (string, error)

ValidCgroupPath returns a valid cgroup path. see https://github.com/opencontainers/runtime-spec/blob/master/config-linux.md#cgroups-path

Types

type LinuxCgroup

type LinuxCgroup struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*LinuxCgroup) AddDevice

func (c *LinuxCgroup) AddDevice(deviceHostPath string) error

func (*LinuxCgroup) AddProcess

func (c *LinuxCgroup) AddProcess(pid int, subsystems ...string) error

func (*LinuxCgroup) AddThread

func (c *LinuxCgroup) AddThread(pid int, subsystems ...string) error

func (*LinuxCgroup) Delete

func (c *LinuxCgroup) Delete() error

func (*LinuxCgroup) ID

func (c *LinuxCgroup) ID() string

func (*LinuxCgroup) Logger

func (c *LinuxCgroup) Logger() *logrus.Entry

func (*LinuxCgroup) MoveTo

func (c *LinuxCgroup) MoveTo(path string) error

func (*LinuxCgroup) Parent

func (c *LinuxCgroup) Parent() string

func (*LinuxCgroup) RemoveDevice

func (c *LinuxCgroup) RemoveDevice(deviceHostPath string) error

func (*LinuxCgroup) Stat

func (c *LinuxCgroup) Stat() (interface{}, error)

func (*LinuxCgroup) Type

func (*LinuxCgroup) Update

func (c *LinuxCgroup) Update(resources *specs.LinuxResources) error

func (*LinuxCgroup) UpdateCpuSet

func (c *LinuxCgroup) UpdateCpuSet(cpuset, memset string) error

type ResourceController

type ResourceController interface {
	// Type returns the resource controller implementation type.
	Type() ResourceControllerType

	// The controller identifier, e.g. a Linux cgroups path.
	ID() string

	// Parent returns the parent controller, on hierarchically
	// defined resource (e.g. Linux cgroups).
	Parent() string

	// Delete the controller.
	Delete() error

	// Stat returns the statistics for the controller.
	Stat() (interface{}, error)

	// AddProcess adds a process to a set of controllers.
	AddProcess(int, ...string) error

	// AddThread adds a process thread to a set of controllers.
	AddThread(int, ...string) error

	// Update updates the set of resources controlled, based on
	// an OCI resources description.
	Update(*specs.LinuxResources) error

	// MoveTo moves a controller to another one.
	MoveTo(string) error

	// AddDevice adds a device resource to the controller.
	AddDevice(string) error

	// RemoveDevice removes a device resource to the controller.
	RemoveDevice(string) error

	// UpdateCpuSet updates the set of controlled CPUs and memory nodes.
	UpdateCpuSet(string, string) error
}

ResourceController represents a system resources controller. On Linux this interface is implemented through the cgroups API.

func LoadResourceController

func LoadResourceController(path string) (ResourceController, error)

func NewResourceController

func NewResourceController(path string, resources *specs.LinuxResources) (ResourceController, error)

func NewSandboxResourceController

func NewSandboxResourceController(path string, resources *specs.LinuxResources, sandboxCgroupOnly bool) (ResourceController, error)

type ResourceControllerType

type ResourceControllerType string

ResourceControllerType describes a resource controller type.

const (
	LinuxCgroups                 ResourceControllerType = "cgroups"
	DarwinResourceControllerType ResourceControllerType = "darwin"
)

func (*ResourceControllerType) String

func (rType *ResourceControllerType) String() string

String converts a resource type to a string.

Jump to

Keyboard shortcuts

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