Documentation ¶
Index ¶
- Constants
- Variables
- func DeterminePoolType(poolName string) string
- type CPUAnnotation
- func (cpuAnnotation CPUAnnotation) ContainerExclusiveCPU(cName string) int
- func (cpuAnnotation CPUAnnotation) ContainerNames() []string
- func (cpuAnnotation CPUAnnotation) ContainerPools(cName string) (pools []string)
- func (cpuAnnotation CPUAnnotation) ContainerSharedCPUTime(cName string) int
- func (cpuAnnotation CPUAnnotation) ContainerTotalCPURequest(pool string, cName string) int
- func (cpuAnnotation CPUAnnotation) Decode(annotation []byte) error
- func (cpuAnnotation CPUAnnotation) IsContainerExists(name string) bool
- type Container
- type Pool
- type PoolConfig
- type Process
Constants ¶
const ( // ExclusivePoolID 是 CPU 池名称中的常量前缀. 表示 CPU 池是独占类型 ExclusivePoolID = "exclusive" // DefaultPoolID 是 CPU 池名称中的常量前缀. 表示 CPU 池是默认类型 DefaultPoolID = "default" // SingleThreadHTPolicy 是 HT 策略池属性的单线程值的常量。设置该值时,只为独占请求分配物理线程 SingleThreadHTPolicy = "singleThreaded" // MultiThreadHTPolicy 是 HT 策略池属性的多线程值的常量。设置此值时,所有兄弟一起分配用于独占请求 MultiThreadHTPolicy = "multiThreaded" )SharedPoolID = "shared"
Variables ¶
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") )
var (
//PoolConfigDir defines the pool configuration file location
PoolConfigDir = "/etc/cpusets-pool"
)
Functions ¶
func DeterminePoolType ¶
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 ¶
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 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