policy

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ExportedResources is the basename of the file container resources are exported to.
	ExportedResources = "resources.sh"
	// ExportSharedCPUs is the shell variable used to export shared container CPUs.
	ExportSharedCPUs = "SHARED_CPUS"
	// ExportIsolatedCPUs is the shell variable used to export isolated container CPUs.
	ExportIsolatedCPUs = "ISOLATED_CPUS"
	// ExportExclusiveCPUs is the shell variable used to export exclusive container CPUs.
	ExportExclusiveCPUs = "EXCLUSIVE_CPUS"
)
View Source
const (
	// MemoryResource is the resource name for memory
	MemoryResource = "memory"
	// CPUResource is the resource name for CPU
	CPUResource = "cpu"
	// MemsetAttribute is the attribute name for assignable memory set
	MemsetAttribute = "memory set"
	// SharedCPUsAttribute is the attribute name for the assignable shared CPU set
	SharedCPUsAttribute = "shared cpuset"
	// ReservedCPUsAttribute is the attribute name for assignable the reserved CPU set
	ReservedCPUsAttribute = "reserved cpuset"
	// IsolatedCPUsAttribute is the attribute name for the assignable isolated CPU set
	IsolatedCPUsAttribute = "isolated cpuset"
)

Node resource topology resource and attribute names. XXX TODO(klihub): We'll probably need to add similar unified consts

for resource types (socket, die, NUMA node, etc.) and use them
in policies (for instance for TA pool 'kind's)

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// Name gets the well-known name of this policy.
	Name() string
	// Description gives a verbose description about the policy implementation.
	Description() string
	// Setup initializes the policy backend with the given options.
	Setup(*BackendOptions) error
	// Reconfigure the policy backend.
	Reconfigure(interface{}) error
	// Start up and sycnhronizes the policy, using the given cache and resource constraints.
	Start() error
	// Sync synchronizes the policy, allocating/releasing the given containers.
	Sync([]cache.Container, []cache.Container) error
	// AllocateResources allocates resources to/for a container.
	AllocateResources(cache.Container) error
	// ReleaseResources release resources of a container.
	ReleaseResources(cache.Container) error
	// UpdateResources updates resource allocations of a container.
	UpdateResources(cache.Container) error
	// HandleEvent processes the given event. The returned boolean indicates whether
	// changes have been made to any of the containers while handling the event.
	HandleEvent(*events.Policy) (bool, error)
	// ExportResourceData provides resource data to export for the container.
	ExportResourceData(cache.Container) map[string]string
	// DescribeMetrics generates policy-specific prometheus metrics data descriptors.
	DescribeMetrics() []*prometheus.Desc
	// PollMetrics provides policy metrics for monitoring.
	PollMetrics() Metrics
	// CollectMetrics generates prometheus metrics from cached/polled policy-specific metrics data.
	CollectMetrics(Metrics) ([]prometheus.Metric, error)
	// GetTopologyZones returns the policy/pool data for 'topology zone' CRDs.
	GetTopologyZones() []*TopologyZone
}

Backend is the policy (decision making logic) interface exposed by implementations.

A backends operates in a set of policy domains. Currently each policy domain corresponds to some particular hardware resource (CPU, memory, cache, etc).

type BackendOptions

type BackendOptions struct {
	// System provides system/HW/topology information
	System system.System
	// System state/cache
	Cache cache.Cache
	// SendEvent is the function for delivering events up to the resource manager.
	SendEvent SendEventFn
	// Config is the policy-specific configuration.
	Config interface{}
}

BackendOptions describes the options for a policy backend instance

type Constraint

type Constraint interface{}

Constraint describes constraint of one hardware domain

type ConstraintSet

type ConstraintSet map[Domain]Constraint

ConstraintSet describes, per hardware domain, the resources available for a policy.

type CreateFn

type CreateFn func(*BackendOptions) Backend

CreateFn is the type for functions used to create a policy instance.

type Domain

type Domain string

Domain represents a hardware resource domain that can be policied by a backend.

const (
	// DomainCPU is the CPU resource domain.
	DomainCPU Domain = "CPU"
	// DomainMemory is the memory resource domain.
	DomainMemory Domain = "Memory"
	// DomainHugePage is the hugepages resource domain.
	DomainHugePage Domain = "HugePages"
	// DomainCache is the CPU cache resource domain.
	DomainCache Domain = "Cache"
	// DomainMemoryBW is the memory resource bandwidth.
	DomainMemoryBW Domain = "MBW"
)

type Metrics

type Metrics interface{}

type Options

type Options struct {
	// SendEvent is the function for delivering events back to the resource manager.
	SendEvent SendEventFn
}

Options describes policy options

type Policy

type Policy interface {
	// ActivePolicy returns the name of the policy backend in use.
	ActivePolicy() string
	// Start starts up policy, prepare for serving resource management requests.
	Start(interface{}) error
	// Reconfigure the policy.
	Reconfigure(interface{}) error
	// Sync synchronizes the state of the active policy.
	Sync([]cache.Container, []cache.Container) error
	// AllocateResources allocates resources to a container.
	AllocateResources(cache.Container) error
	// ReleaseResources releases resources of a container.
	ReleaseResources(cache.Container) error
	// UpdateResources updates resource allocations of a container.
	UpdateResources(cache.Container) error
	// HandleEvent passes on the given event to the active policy. The returned boolean
	// indicates whether changes have been made to any of the containers while handling
	// the event.
	HandleEvent(*events.Policy) (bool, error)
	// ExportResourceData exports/updates resource data for the container.
	ExportResourceData(cache.Container)
	// DescribeMetrics generates policy-specific prometheus metrics data descriptors.
	DescribeMetrics() []*prometheus.Desc
	// PollMetrics provides policy metrics for monitoring.
	PollMetrics() Metrics
	// CollectMetrics generates prometheus metrics from cached/polled policy-specific metrics data.
	CollectMetrics(Metrics) ([]prometheus.Metric, error)
	// GetTopologyZones returns the policy/pool data for 'topology zone' CRDs.
	GetTopologyZones() []*TopologyZone
}

Policy is the exposed interface for container resource allocations decision making.

func NewPolicy

func NewPolicy(backend Backend, cache cache.Cache, o *Options) (Policy, error)

NewPolicy creates a policy instance using the given backend.

type SendEventFn

type SendEventFn func(interface{}) error

SendEventFn is the type for a function to send events back to the resource manager.

type TopologyZone

type TopologyZone struct {
	Name       string
	Parent     string
	Type       string
	Resources  []*ZoneResource
	Attributes []*ZoneAttribute
}

TopologyZone provides policy-/pool-specific data for 'node resource topology' CRs.

type ZoneAttribute

type ZoneAttribute struct {
	Name  string
	Value string
}

ZoneAttribute represents additional, policy-specific information about a zone.

type ZoneResource

type ZoneResource struct {
	Name        string
	Capacity    resource.Quantity
	Allocatable resource.Quantity
	Available   resource.Quantity
}

ZoneResource is a resource available in some TopologyZone.

Jump to

Keyboard shortcuts

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