cgmgr

package
v1.19.4 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCgroupManager = systemdCgroupManager
)

Variables

This section is empty.

Functions

func VerifyMemoryIsEnough

func VerifyMemoryIsEnough(memoryLimit int64) error

Types

type CgroupManager

type CgroupManager interface {
	// String returns the name of the cgroup manager (either cgroupfs or systemd)
	Name() string
	// IsSystemd returns whether it is a systemd cgroup manager
	IsSystemd() bool
	// ContainerCgroupPath takes arguments sandbox parent cgroup and container ID and returns
	// the cgroup path for that containerID. If parentCgroup is empty, it
	// uses the default parent for that particular manager
	ContainerCgroupPath(string, string) string
	// ContainerCgroupAbsolutePath takes arguments sandbox parent cgroup and container ID and
	// returns the cgroup path on disk for that containerID. If parentCgroup is empty, it
	// uses the default parent for that particular manager
	ContainerCgroupAbsolutePath(string, string) (string, error)
	// SandboxCgroupPath takes the sandbox parent, and sandbox ID. It
	// returns the cgroup parent, cgroup path, and error. For systemd cgroups,
	// it also checks there is enough memory in the given cgroup
	SandboxCgroupPath(string, string) (string, string, error)
	// MoveConmonToCgroup takes the container ID, cgroup parent, conmon's cgroup (from the config) and conmon's PID
	// It attempts to move conmon to the correct cgroup.
	// It returns the cgroupfs parent that conmon was put into
	// so that CRI-O can clean the parent cgroup of the newly added conmon once the process terminates (systemd handles this for us)
	MoveConmonToCgroup(cid, cgroupParent, conmonCgroup string, pid int) (string, error)
}

CgroupManager is an interface to interact with cgroups on a node. CRI-O is configured at startup to either use systemd or cgroupfs, and the node itself is booted with cgroup v1, or cgroup v2. CgroupManager is an interface for the CRI-O server to use cgroups, regardless of how it or the node was configured.

func New

func New() CgroupManager

New creates a new CgroupManager with defaults

func SetCgroupManager

func SetCgroupManager(cgroupManager string) (CgroupManager, error)

SetCgroupManager takes a string and branches on it to return the type of cgroup manager configured

type CgroupfsManager

type CgroupfsManager struct{}

func (*CgroupfsManager) ContainerCgroupAbsolutePath

func (m *CgroupfsManager) ContainerCgroupAbsolutePath(sbParent, containerID string) (string, error)

ContainerCgroupAbsolutePath just calls ContainerCgroupPath, because they both return the absolute path

func (*CgroupfsManager) ContainerCgroupPath

func (*CgroupfsManager) ContainerCgroupPath(sbParent, containerID string) string

ContainerCgroupPath takes arguments sandbox parent cgroup and container ID and returns the cgroup path for that containerID. If parentCgroup is empty, it uses the default parent /crio

func (*CgroupfsManager) IsSystemd

func (*CgroupfsManager) IsSystemd() bool

IsSystemd returns that this is not a systemd cgroup manager

func (*CgroupfsManager) MoveConmonToCgroup

func (*CgroupfsManager) MoveConmonToCgroup(cid, cgroupParent, conmonCgroup string, pid int) (string, error)

MoveConmonToCgroup takes the container ID, cgroup parent, conmon's cgroup (from the config) and conmon's PID It attempts to move conmon to the correct cgroup. It returns the cgroupfs parent that conmon was put into so that CRI-O can clean the cgroup path of the newly added conmon once the process terminates (systemd handles this for us)

func (*CgroupfsManager) Name

func (*CgroupfsManager) Name() string

Name returns the name of the cgroup manager (cgroupfs)

func (*CgroupfsManager) SandboxCgroupPath

func (*CgroupfsManager) SandboxCgroupPath(sbParent, sbID string) (cgParent, cgPath string, _ error)

SandboxCgroupPath takes the sandbox parent, and sandbox ID. It returns the cgroup parent, cgroup path, and error.

type SystemdManager

type SystemdManager struct {
	// contains filtered or unexported fields
}

SystemdManager is the parent type of SystemdV{1,2}Manager. it defines all of the common functionality between V1 and V2

func NewSystemdManager added in v1.19.3

func NewSystemdManager() *SystemdManager

func (*SystemdManager) ContainerCgroupAbsolutePath

func (*SystemdManager) ContainerCgroupAbsolutePath(sbParent, containerID string) (string, error)

ContainerCgroupAbsolutePath takes arguments sandbox parent cgroup and container ID and returns the cgroup path on disk for that containerID. If parentCgroup is empty, it uses the default parent system.slice

func (*SystemdManager) ContainerCgroupPath

func (*SystemdManager) ContainerCgroupPath(sbParent, containerID string) string

ContainerCgroupPath takes arguments sandbox parent cgroup and container ID and returns the cgroup path for that containerID. If parentCgroup is empty, it uses the default parent system.slice

func (*SystemdManager) IsSystemd

func (*SystemdManager) IsSystemd() bool

IsSystemd returns that it is a systemd cgroup manager

func (*SystemdManager) MoveConmonToCgroup

func (m *SystemdManager) MoveConmonToCgroup(cid, cgroupParent, conmonCgroup string, pid int) (cgroupPathToClean string, _ error)

MoveConmonToCgroup takes the container ID, cgroup parent, conmon's cgroup (from the config) and conmon's PID It attempts to move conmon to the correct cgroup. cgroupPathToClean should always be returned empty. It is part of the interface to return the cgroup path that cri-o is responsible for cleaning up upon the container's death. Systemd takes care of this cleaning for us, so return an empty string

func (*SystemdManager) Name

func (*SystemdManager) Name() string

Name returns the name of the cgroup manager (systemd)

func (*SystemdManager) SandboxCgroupPath

func (m *SystemdManager) SandboxCgroupPath(sbParent, sbID string) (cgParent, cgPath string, _ error)

SandboxCgroupPath takes the sandbox parent, and sandbox ID. It returns the cgroup parent, cgroup path, and error. It also checks there is enough memory in the given cgroup

Jump to

Keyboard shortcuts

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