cgroup

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package cgroup provides utilities for linux devices cgroups

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DirPath

func DirPath() (string, error)

DirPath returns cgroup dir path pattern matching all pod containers

Types

type Cgroup

type Cgroup struct {
	Path string
}

Cgroup represents linux devices cgroup

func NewCgroups

func NewCgroups(pathPattern string) (cgroups []*Cgroup, err error)

NewCgroups returns all cgroups matching pathPattern

func NewFakeCgroup

func NewFakeCgroup(ctx context.Context, path string) (*Cgroup, error)

NewFakeCgroup creates and returns a new cgroup for testing with some k8s default devices allowed.

func NewFakeWideCgroup

func NewFakeWideCgroup(ctx context.Context, path string) (*Cgroup, error)

NewFakeWideCgroup creates and returns a new cgroup for testing with "a *:* rwm" allowed

func (*Cgroup) Allow

func (c *Cgroup) Allow(major, minor uint32) error

Allow allows "c major:minor rwm" for cgroup

func (*Cgroup) Deny

func (c *Cgroup) Deny(major, minor uint32) error

Deny denies "c major:minor rw" for cgroup

func (*Cgroup) IsAllowed

func (c *Cgroup) IsAllowed(major, minor uint32) (bool, error)

IsAllowed returns if "c major:minor rwm" is allowed for cgroup

func (*Cgroup) IsWiderThan

func (c *Cgroup) IsWiderThan(major, minor uint32) (bool, error)

IsWiderThan returns if cgroup allows wider device group than "c major:minor rwm":

  • "a *:minor rwm"
  • "a major:* rwm"
  • "a *:* rwm"
  • "c *:minor rwm"
  • "c major:* rwm"
  • "c *:* rwm"

Jump to

Keyboard shortcuts

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