Documentation ¶
Overview ¶
Package equivalence defines Pod equivalence classes and the equivalence class cache.
Index ¶
- type Cache
- func (c *Cache) GetNodeCache(name string) (nodeCache *NodeCache, exists bool)
- func (c *Cache) InvalidateAllPredicatesOnNode(nodeName string)
- func (c *Cache) InvalidateCachedPredicateItemForPodAdd(pod *v1.Pod, nodeName string)
- func (c *Cache) InvalidatePredicates(predicateKeys sets.String)
- func (c *Cache) InvalidatePredicatesOnNode(nodeName string, predicateKeys sets.String)
- func (c *Cache) LoadNodeCache(node string) *NodeCache
- func (c *Cache) Snapshot()
- type Class
- type NodeCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
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 (*Cache) GetNodeCache ¶
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 ¶
InvalidateAllPredicatesOnNode clears all cached results for one node.
func (*Cache) InvalidateCachedPredicateItemForPodAdd ¶
InvalidateCachedPredicateItemForPodAdd is a wrapper of InvalidateCachedPredicateItem for pod add case TODO: This does not belong with the equivalence cache implementation.
func (*Cache) InvalidatePredicates ¶
InvalidatePredicates clears all cached results for the given predicates.
func (*Cache) InvalidatePredicatesOnNode ¶
InvalidatePredicatesOnNode clears cached results for the given predicates on one node.
func (*Cache) LoadNodeCache ¶ added in v1.13.0
LoadNodeCache returns the existing NodeCache for given node, nil if not present.
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 ¶
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, predicateID int, pod *v1.Pod, meta algorithm.PredicateMetadata, nodeInfo *schedulercache.NodeInfo, equivClass *Class, ) (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 generation does not match live version.