mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-17 11:28:58 +00:00
Add GetNode method to scheduler cache for testing
This commit is contained in:
13
pkg/scheduler/backend/cache/cache.go
vendored
13
pkg/scheduler/backend/cache/cache.go
vendored
@@ -649,6 +649,19 @@ func (cache *cacheImpl) RemoveNode(logger klog.Logger, node *v1.Node) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetNode returns the copy of node stored in the cache.
|
||||
// DO NOT use outside of tests.
|
||||
func (cache *cacheImpl) GetNode(name string) (*framework.NodeInfo, error) {
|
||||
cache.mu.RLock()
|
||||
defer cache.mu.RUnlock()
|
||||
|
||||
n, ok := cache.nodes[name]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("node %v does not exist in scheduler cache", name)
|
||||
}
|
||||
return n.info.SnapshotConcrete(), nil
|
||||
}
|
||||
|
||||
// addNodeImageStates adds states of the images on given node to the given nodeInfo and update the imageStates in
|
||||
// scheduler cache. This function assumes the lock to scheduler cache has been acquired.
|
||||
func (cache *cacheImpl) addNodeImageStates(node *v1.Node, nodeInfo *framework.NodeInfo) {
|
||||
|
||||
4
pkg/scheduler/backend/cache/interface.go
vendored
4
pkg/scheduler/backend/cache/interface.go
vendored
@@ -61,6 +61,10 @@ type Cache interface {
|
||||
// DO NOT use outside of tests.
|
||||
PodCount() (int, error)
|
||||
|
||||
// GetNode returns the copy of node stored in the cache.
|
||||
// DO NOT use outside of tests.
|
||||
GetNode(name string) (*framework.NodeInfo, error)
|
||||
|
||||
// AssumePod assumes a pod scheduled and aggregates the pod's information into its node.
|
||||
AssumePod(logger klog.Logger, pod *v1.Pod) error
|
||||
|
||||
|
||||
Reference in New Issue
Block a user