Documentation
¶
Index ¶
- Constants
- func ActivePolicy() string
- func ConstraintToString(value Constraint) string
- func DefaultPolicy() string
- func Register(name, description string, create CreateFn) error
- type AvailablePolicy
- type Backend
- type BackendOptions
- type Constraint
- type ConstraintSet
- type CreateFn
- type Domain
- type Metrics
- type Options
- type Policy
- type SendEventFn
- type TopologyZone
- type ZoneAttribute
- type ZoneResource
Constants ¶
const ( // ExportedResources is the basename of the file container resources are exported to. ExportedResources = "resources.sh" 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" )
const ( // MemoryResource is 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 = "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)
const (
// ConfigPath is the configuration module path for the generic policy layer.
ConfigPath = "policy"
)
Variables ¶
This section is empty.
Functions ¶
func ActivePolicy ¶
func ActivePolicy() string
ActivePolicy returns the name of the policy to be activated.
func ConstraintToString ¶
func ConstraintToString(value Constraint) string
ConstraintToString returns the given constraint as a string.
func DefaultPolicy ¶
func DefaultPolicy() string
DefaultPolicy returns the name of the default policy.
Types ¶
type AvailablePolicy ¶
type AvailablePolicy struct {
// Name is the name of the policy.
Name string
// Description is a short description of the policy.
Description string
}
AvailablePolicy describes an available policy.
func AvailablePolicies ¶
func AvailablePolicies() []*AvailablePolicy
AvailablePolicies returns the available policies and their descriptions.
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
// Start up and sycnhronizes the policy, using the given cache and resource constraints.
Start([]cache.Container, []cache.Container) 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
// Resource availibility constraint
Available ConstraintSet
// Resource reservation constraint
Reserved ConstraintSet
// SendEvent is the function for delivering events up to the resource manager.
SendEvent SendEventFn
}
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.
func (ConstraintSet) MarshalJSON ¶
func (cs ConstraintSet) MarshalJSON() ([]byte, error)
MarshalJSON implements JSON marshalling for ConstraintSets.
func (*ConstraintSet) String ¶
func (cs *ConstraintSet) String() string
func (*ConstraintSet) UnmarshalJSON ¶
func (cs *ConstraintSet) UnmarshalJSON(raw []byte) error
UnmarshalJSON implements JSON unmarshalling for ConstraintSets.
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 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 {
// Start starts up policy, prepare for serving resource management requests.
Start([]cache.Container, []cache.Container) 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.
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 ¶
ZoneAttribute represents additional, policy-specific information about a zone.