cgutil

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CgroupRoot is hard-coded in the cgroups specification.
	// It only applies to linux but helpers have references to it in driver(s).
	CgroupRoot = "/sys/fs/cgroup"
)
View Source
const (
	// DefaultCgroupParent does not apply to non-Linux operating systems.
	DefaultCgroupParent = ""
)

Variables

View Source
var UseV2 = false

UseV2 is always false on non-Linux systems.

This is a read-only value.

Functions

func CgroupScope added in v1.3.0

func CgroupScope(allocID, task string) string

CgroupScope returns nothing for non-Linux operating systems.

func FindCgroupMountpointDir

func FindCgroupMountpointDir() (string, error)

FindCgroupMountpointDir returns nothing for non-Linux operating systems.

func GetCPUsFromCgroup added in v1.3.0

func GetCPUsFromCgroup(string) ([]uint16, error)

GetCPUsFromCgroup returns nothing for non-Linux operating systems.

func GetCgroupParent added in v1.3.0

func GetCgroupParent(string) string

GetCgroupParent returns nothing for non-Linux operating systems.

func SplitPath added in v1.3.0

func SplitPath(p string) (string, string)

SplitPath determines the parent and cgroup from p. p must contain at least 2 elements (parent + cgroup).

Handles the cgroup root if present.

Types

type CgroupPathGetter

type CgroupPathGetter func(context.Context) (path string, err error)

CgroupPathGetter is a function which returns the cgroup path and any error which occurred during cgroup initialization.

It should block until the cgroup has been created or an error is reported.

type CpusetManager

type CpusetManager interface {
	// Init should be called with the initial set of reservable cores before any
	// allocations are managed. Ensures the parent cgroup exists and proper permissions
	// are available for managing cgroups.
	Init([]uint16) error

	// AddAlloc adds an allocation to the manager
	AddAlloc(alloc *structs.Allocation)

	// RemoveAlloc removes an alloc by ID from the manager
	RemoveAlloc(allocID string)

	// CgroupPathFor returns a callback for getting the cgroup path and any error that may have occurred during
	// cgroup initialization. The callback will block if the cgroup has not been created
	CgroupPathFor(allocID, taskName string) CgroupPathGetter
}

CpusetManager is used to setup cpuset cgroups for each task.

func CreateCPUSetManager added in v1.3.0

func CreateCPUSetManager(string, hclog.Logger) CpusetManager

CreateCPUSetManager creates a no-op CpusetManager for non-Linux operating systems.

type NoopCpusetManager

type NoopCpusetManager struct{}

func (NoopCpusetManager) AddAlloc added in v1.3.0

func (n NoopCpusetManager) AddAlloc(alloc *structs.Allocation)

func (NoopCpusetManager) CgroupPathFor added in v1.3.0

func (n NoopCpusetManager) CgroupPathFor(allocID, task string) CgroupPathGetter

func (NoopCpusetManager) Init added in v1.3.0

func (n NoopCpusetManager) Init([]uint16) error

func (NoopCpusetManager) RemoveAlloc added in v1.3.0

func (n NoopCpusetManager) RemoveAlloc(allocID string)

type TaskCgroupInfo

type TaskCgroupInfo struct {
	CgroupPath         string
	RelativeCgroupPath string
	Cpuset             cpuset.CPUSet
	Error              error
}

Jump to

Keyboard shortcuts

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