Merge pull request #137775 from macsko/add_getnode_method_to_cache

Add GetNode method to scheduler cache for testing
This commit is contained in:
Kubernetes Prow Robot
2026-03-16 23:37:55 +05:30
committed by GitHub
2 changed files with 17 additions and 0 deletions

View File

@@ -696,6 +696,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) {

View File

@@ -62,6 +62,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