equivalence

package
v1.12.2-lite1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package equivalence defines Pod equivalence classes and the equivalence class cache.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// i.e. map[string]*NodeCache
	sync.Map
}

Cache is a thread safe map saves and reuses the output of predicate functions, it uses node name as key to access those cached results.

Internally, results are keyed by predicate name, and "equivalence class". (Equivalence class is defined in the `Class` type.) Saved results will be reused until an appropriate invalidation function is called.

func NewCache

func NewCache() *Cache

NewCache create an empty equiv class cache.

func (*Cache) GetNodeCache

func (c *Cache) GetNodeCache(name string) (nodeCache *NodeCache, exists bool)

GetNodeCache returns the existing NodeCache for given node if present. Otherwise, it creates the NodeCache and returns it. The boolean flag is true if the value was loaded, false if created.

func (*Cache) InvalidateAllPredicatesOnNode

func (c *Cache) InvalidateAllPredicatesOnNode(nodeName string)

InvalidateAllPredicatesOnNode clears all cached results for one node.

func (*Cache) InvalidateCachedPredicateItemForPodAdd

func (c *Cache) InvalidateCachedPredicateItemForPodAdd(pod *v1.Pod, nodeName string)

InvalidateCachedPredicateItemForPodAdd is a wrapper of InvalidateCachedPredicateItem for pod add case TODO: This does not belong with the equivalence cache implementation.

func (*Cache) InvalidatePredicates

func (c *Cache) InvalidatePredicates(predicateKeys sets.String)

InvalidatePredicates clears all cached results for the given predicates.

func (*Cache) InvalidatePredicatesOnNode

func (c *Cache) InvalidatePredicatesOnNode(nodeName string, predicateKeys sets.String)

InvalidatePredicatesOnNode clears cached results for the given predicates on one node.

type Class

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

Class represents a set of pods which are equivalent from the perspective of the scheduler. i.e. the scheduler would make the same decision for any pod from the same class.

func NewClass

func NewClass(pod *v1.Pod) *Class

NewClass returns the equivalence class for a given Pod. The returned Class objects will be equal for two Pods in the same class. nil values should not be considered equal to each other.

NOTE: Make sure to compare types of Class and not *Class. TODO(misterikkit): Return error instead of nil *Class.

type NodeCache

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

NodeCache saves and reuses the output of predicate functions. Use RunPredicate to get or update the cached results. An appropriate Invalidate* function should be called when some predicate results are no longer valid.

Internally, results are keyed by predicate name, and "equivalence class". (Equivalence class is defined in the `Class` type.) Saved results will be reused until an appropriate invalidation function is called.

NodeCache objects are thread safe within the context of NodeCache,

func (*NodeCache) RunPredicate

func (n *NodeCache) RunPredicate(
	pred algorithm.FitPredicate,
	predicateKey string,
	pod *v1.Pod,
	meta algorithm.PredicateMetadata,
	nodeInfo *schedulercache.NodeInfo,
	equivClass *Class,
	cache schedulercache.Cache,
) (bool, []algorithm.PredicateFailureReason, error)

RunPredicate returns a cached predicate result. In case of a cache miss, the predicate will be run and its results cached for the next call.

NOTE: RunPredicate will not update the equivalence cache if the given NodeInfo is stale.

Jump to

Keyboard shortcuts

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