common

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxControllerTimeout is max timeout (s) between each intent's reevaluation.
	MaxControllerTimeout = 600
	// MaxInformerTimeout is max timeout (s) for the informer factories for the CRDs and PODs.
	MaxInformerTimeout = 300
	// MaxTaskChannelLen is max length for job queue for processing intents.
	MaxTaskChannelLen = 10000
	// MaxPlanCacheTimeout is max timeout (ms) between each intent's reevaluation.
	MaxPlanCacheTimeout = 50000
	// MaxPlanCacheTTL is max time-to-live (ms) for an entry in the planner's cache.
	MaxPlanCacheTTL = 500000
)

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(filename string, createType func() interface{}) (interface{}, error)

LoadConfig reads the configuration file and marshals it into an object.

Types

type Config

type Config struct {
	Generic    GenericConfig    `json:"generic"`
	Controller ControllerConfig `json:"controller"`
	Monitor    MonitorConfig    `json:"monitor"`
	Planner    PlannerConfig    `json:"planner"`
}

Config holds all the configuration information.

func ParseConfig

func ParseConfig(filename string) (Config, error)

ParseConfig loads the configuration from a JSON file.

type ControllerConfig

type ControllerConfig struct {
	Workers           int    `json:"workers"`
	TaskChannelLength int    `json:"task_channel_length"`
	InformerTimeout   int    `json:"informer_timeout"`
	ControllerTimeout int    `json:"controller_timeout"`
	PlanCacheTTL      int    `json:"plan_cache_ttl"`
	PlanCacheTimeout  int    `json:"plan_cache_timeout"`
	TelemetryEndpoint string `json:"telemetry_endpoint"`
	HostField         string `json:"host_field"`
	Metrics           []struct {
		Name  string `json:"name,omitempty"`
		Query string `json:"query,omitempty"`
	} `json:"metrics"`
}

ControllerConfig holds controller related configs.

type GenericConfig

type GenericConfig struct {
	MongoEndpoint string `json:"mongo_endpoint"`
}

GenericConfig captures generic configuration fields.

type Intent

type Intent struct {
	Key        string
	Priority   float64
	TargetKey  string
	TargetKind string
	Objectives map[string]float64
}

Intent holds information about an intent in the system.

type MonitorConfig

type MonitorConfig struct {
	Pod struct {
		Workers int `json:"workers"`
	} `json:"pod"`
	Profile struct {
		Workers int    `json:"workers"`
		Queries string `json:"queries"`
	} `json:"profile"`
	Intent struct {
		Workers int `json:"workers"`
	} `json:"intent"`
}

MonitorConfig holds monitor related configs.

type PlannerConfig

type PlannerConfig struct {
	AStar struct {
		OpportunisticCandidates int    `json:"opportunistic_candidates"`
		MaxStates               int    `json:"max_states"`
		MaxCandidates           int    `json:"max_candidates"`
		PluginManagerEndpoint   string `json:"plugin_manager_endpoint"`
		PluginManagerPort       int    `json:"plugin_manager_port"`
	} `json:"astar"`
}

PlannerConfig holds planner related configs. TODO: fuzz test max states, candidates etc.

type PodError

type PodError struct {
	Key     string
	Start   time.Time
	End     time.Time
	Created time.Time
}

PodError holds start and end time for an error of a POD.

type PodState

type PodState struct {
	Availability float64
	NodeName     string
	State        string
	QoSClass     string
}

PodState represents the state of an POD.

type Profile

type Profile struct {
	Key         string
	ProfileType ProfileType
	Query       string
	External    bool
	Address     string
}

Profile holds information about valid objective profiles.

type ProfileType

type ProfileType int

ProfileType defines the type of KPIProfiles.

const (
	Obsolete ProfileType = iota
	Latency
	Availability
	Throughput
	Power
)

func ProfileTypeFromText

func ProfileTypeFromText(text string) ProfileType

ProfileTypeFromText converts string into the right int.

type State

type State struct {
	Intent      Intent
	CurrentPods map[string]PodState
	CurrentData map[string]map[string]float64
	Resources   map[string]int64
	Annotations map[string]string
}

State represents the state a set of PODs can be in.

func (*State) DeepCopy

func (one *State) DeepCopy() State

DeepCopy creates a deep copy of a state.

func (*State) Distance

func (one *State) Distance(another *State, profiles map[string]Profile) float64

Distance calculates the euclidean Distance between two states. Potentially we can add weights here maybe - or another way to calculate the Distance so e.g. the Distance for P99 is more important than the Distance in P50 latency.

func (*State) IsBetter added in v0.2.0

func (one *State) IsBetter(another *State, profiles map[string]Profile) bool

IsBetter compares the objectives of one state to another - returns true if all latency or power related objective targets are smaller or equal, and all others are larger or equal.

func (*State) LessResources added in v0.2.0

func (one *State) LessResources(another *State) bool

LessResources contrast the resources and returns true if one state has less resource than another.

type TTLCache

type TTLCache struct {
	// contains filtered or unexported fields
}

TTLCache represents a super simple TTL cache.

func NewCache

func NewCache(ttl int, tick time.Duration) (*TTLCache, chan struct{})

NewCache initializes a new TTL based cache that actively evicts old entries.

func (*TTLCache) IsIn

func (c *TTLCache) IsIn(key string) bool

IsIn checks if an entry still exists.

func (*TTLCache) Put

func (c *TTLCache) Put(key string)

Put adds an entry to the Cache.

Jump to

Keyboard shortcuts

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