types

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SharedPoolID 是 CPU 池名称中的常量前缀. 表示 CPU 池是共享类型的
	SharedPoolID = "shared"
	// ExclusivePoolID 是 CPU 池名称中的常量前缀. 表示 CPU 池是独占类型
	ExclusivePoolID = "exclusive"
	// DefaultPoolID 是 CPU 池名称中的常量前缀. 表示 CPU 池是默认类型
	DefaultPoolID = "default"
	// SingleThreadHTPolicy 是 HT 策略池属性的单线程值的常量。设置该值时,只为独占请求分配物理线程
	SingleThreadHTPolicy = "singleThreaded"
	// MultiThreadHTPolicy 是 HT 策略池属性的多线程值的常量。设置此值时,所有兄弟一起分配用于独占请求
	MultiThreadHTPolicy = "multiThreaded"
)

Variables

View Source
var (
	ErrNoContainerName = errors.New("'container' is mandatory in annotation")
	ErrNoProcesses     = errors.New("'processes' is mandatory in annotation")
	ErrNoProcessName   = errors.New("'process' (name) is mandatory in annotation")
	ErrNoCpus          = errors.New("'cpus' field is mandatory in annotation")

	ErrNotReadPoolConfig  = errors.New("could not read poolconfig file")
	ErrNotParsePoolConfig = errors.New("could not parse poolconfig file")
	ErrNotMatchPoolConfig = errors.New("no matching pool configuration file found for provided nodeSelector label")

	ErrCallAPIServerNodeInfo = errors.New("following error happend when trying to read K8s API server Node object")
)
View Source
var (
	//PoolConfigDir defines the pool configuration file location
	PoolConfigDir = "/etc/cpusets-pool"
)

Functions

func DeterminePoolType

func DeterminePoolType(poolName string) string

DeterminePoolType takes the name of CPU pool as defined in the CPUSets ConfigMap, and returns the type of CPU pool it represents. Type of the pool is determined based on the constant prefixes used in the name of the pool. A type can be shared, exclusive, or default.

Types

type CPUAnnotation

type CPUAnnotation map[string]Container

func NewCPUAnnotation

func NewCPUAnnotation() CPUAnnotation

NewCPUAnnotation returns a new CPUAnnotation

func (CPUAnnotation) ContainerExclusiveCPU

func (cpuAnnotation CPUAnnotation) ContainerExclusiveCPU(cName string) int

ContainerExclusiveCPU returns sum of cpu time requested from exclusive pool by a container

func (CPUAnnotation) ContainerNames

func (cpuAnnotation CPUAnnotation) ContainerNames() []string

Containers returns container name string in annotation

func (CPUAnnotation) ContainerPools

func (cpuAnnotation CPUAnnotation) ContainerPools(cName string) (pools []string)

ContainerPools returns all pools configured for container

func (CPUAnnotation) ContainerSharedCPUTime

func (cpuAnnotation CPUAnnotation) ContainerSharedCPUTime(cName string) int

ContainerSharedCPUTime returns sum of cpu time requested from shared pool by a container

func (CPUAnnotation) ContainerTotalCPURequest

func (cpuAnnotation CPUAnnotation) ContainerTotalCPURequest(pool string, cName string) int

ContainerTotalCPURequest returns CPU requests of container from pool

func (CPUAnnotation) Decode

func (cpuAnnotation CPUAnnotation) Decode(annotation []byte) error

Decode unmarshals json annotation to CPUAnnotation

func (CPUAnnotation) IsContainerExists

func (cpuAnnotation CPUAnnotation) IsContainerExists(name string) bool

IsContainerExists tells if container exist in annotation

type Container

type Container struct {
	Name      string    `json:"container"`
	Processes []Process `json:"processes"`
}

Container idenfifies container and defines the processes to be started

type Pool

type Pool struct {
	CPUset   cpuset.CPUSet
	CPUStr   string `yaml:"cpus"`
	HTPolicy string `yaml:"hyperThreadingPolicy"`
}

Pool defines cpupool

type PoolConfig

type PoolConfig struct {
	Pools        map[string]Pool   `yaml:"pools"`
	NodeSelector map[string]string `yaml:"nodeSelector"`
}

PoolConfig defines pool configuration for a node

func DeterminePoolConfig

func DeterminePoolConfig(k8sclient k8sclient.Interface, fileMatch, nodeName string) (PoolConfig, error)

DeterminePoolConfig first interrogates the label set of the Node this process runs on. It uses this information to select the specific PoolConfig file corresponding to the Node. Returns the selected PoolConfig file, the name of the file, or an error if it was impossible to determine which config file is applicable.

func ReadAllPoolConfigs

func ReadAllPoolConfigs(fileMatch string) ([]PoolConfig, error)

ReadAllPoolConfigs reads all the CPU pools configured in the cluster, and returns them to the user in one big array

func (*PoolConfig) SelectPoolConfig

func (p *PoolConfig) SelectPoolConfig(prefix string) Pool

SelectPool returns the exact CPUSet belonging to either the exclusive, shared, or default pool of one PoolConfig object An empty CPUSet is returned in case the configuration does not contain the requested type

type Process

type Process struct {
	ProcName string   `json:"process"`
	Args     []string `json:"args"`
	CPUs     int      `json:"cpus"`
	PoolName string   `json:"pool"`
}

Process defines Process Information in pod annotation The information is used for setting CPU-Affinity

Jump to

Keyboard shortcuts

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