diff --git a/pkg/scheduler/internal/cache/cache.go b/pkg/scheduler/internal/cache/cache.go index 1d3fbb420ad..75ada0dfd29 100644 --- a/pkg/scheduler/internal/cache/cache.go +++ b/pkg/scheduler/internal/cache/cache.go @@ -177,7 +177,7 @@ func (cache *schedulerCache) removeNodeInfoFromList(name string) { // debugging purposes only and shouldn't be confused with UpdateNodeInfoSnapshot // function. // This method is expensive, and should be only used in non-critical path. -func (cache *schedulerCache) Snapshot() *Snapshot { +func (cache *schedulerCache) Dump() *Dump { cache.mu.RLock() defer cache.mu.RUnlock() @@ -191,7 +191,7 @@ func (cache *schedulerCache) Snapshot() *Snapshot { assumedPods[k] = v } - return &Snapshot{ + return &Dump{ Nodes: nodes, AssumedPods: assumedPods, } diff --git a/pkg/scheduler/internal/cache/cache_test.go b/pkg/scheduler/internal/cache/cache_test.go index c6630b4ce3a..d3abfe53033 100644 --- a/pkg/scheduler/internal/cache/cache_test.go +++ b/pkg/scheduler/internal/cache/cache_test.go @@ -398,7 +398,7 @@ func TestSnapshot(t *testing.T) { } } - snapshot := cache.Snapshot() + snapshot := cache.Dump() if len(snapshot.Nodes) != len(cache.nodes) { t.Errorf("Unequal number of nodes in the cache and its snapshot. expected: %v, got: %v", len(cache.nodes), len(snapshot.Nodes)) } diff --git a/pkg/scheduler/internal/cache/debugger/comparer.go b/pkg/scheduler/internal/cache/debugger/comparer.go index fce703d87fe..38c7cd7311b 100644 --- a/pkg/scheduler/internal/cache/debugger/comparer.go +++ b/pkg/scheduler/internal/cache/debugger/comparer.go @@ -52,15 +52,15 @@ func (c *CacheComparer) Compare() error { return err } - snapshot := c.Cache.Snapshot() + dump := c.Cache.Dump() pendingPods := c.PodQueue.PendingPods() - if missed, redundant := c.CompareNodes(nodes, snapshot.Nodes); len(missed)+len(redundant) != 0 { + if missed, redundant := c.CompareNodes(nodes, dump.Nodes); len(missed)+len(redundant) != 0 { klog.Warningf("cache mismatch: missed nodes: %s; redundant nodes: %s", missed, redundant) } - if missed, redundant := c.ComparePods(pods, pendingPods, snapshot.Nodes); len(missed)+len(redundant) != 0 { + if missed, redundant := c.ComparePods(pods, pendingPods, dump.Nodes); len(missed)+len(redundant) != 0 { klog.Warningf("cache mismatch: missed pods: %s; redundant pods: %s", missed, redundant) } diff --git a/pkg/scheduler/internal/cache/debugger/dumper.go b/pkg/scheduler/internal/cache/debugger/dumper.go index 6291b1f0629..601e13c9011 100644 --- a/pkg/scheduler/internal/cache/debugger/dumper.go +++ b/pkg/scheduler/internal/cache/debugger/dumper.go @@ -43,9 +43,9 @@ func (d *CacheDumper) DumpAll() { // dumpNodes writes NodeInfo to the scheduler logs. func (d *CacheDumper) dumpNodes() { - snapshot := d.cache.Snapshot() + dump := d.cache.Dump() klog.Info("Dump of cached NodeInfo") - for _, nodeInfo := range snapshot.Nodes { + for _, nodeInfo := range dump.Nodes { klog.Info(d.printNodeInfo(nodeInfo)) } } diff --git a/pkg/scheduler/internal/cache/fake/fake_cache.go b/pkg/scheduler/internal/cache/fake/fake_cache.go index e13c2f06ae6..ad14bd6bf79 100644 --- a/pkg/scheduler/internal/cache/fake/fake_cache.go +++ b/pkg/scheduler/internal/cache/fake/fake_cache.go @@ -89,8 +89,8 @@ func (c *Cache) FilteredList(filter schedulerlisters.PodFilter, selector labels. } // Snapshot is a fake method for testing -func (c *Cache) Snapshot() *internalcache.Snapshot { - return &internalcache.Snapshot{} +func (c *Cache) Dump() *internalcache.Dump { + return &internalcache.Dump{} } // GetNodeInfo is a fake method for testing. diff --git a/pkg/scheduler/internal/cache/interface.go b/pkg/scheduler/internal/cache/interface.go index a4c47cc0cc3..ac8f935f9a9 100644 --- a/pkg/scheduler/internal/cache/interface.go +++ b/pkg/scheduler/internal/cache/interface.go @@ -102,12 +102,12 @@ type Cache interface { // on this node. UpdateNodeInfoSnapshot(nodeSnapshot *nodeinfosnapshot.Snapshot) error - // Snapshot takes a snapshot on current cache - Snapshot() *Snapshot + // Dump produces a dump of the current cache. + Dump() *Dump } -// Snapshot is a snapshot of cache state -type Snapshot struct { +// Dump is a dump of the cache state. +type Dump struct { AssumedPods map[string]bool Nodes map[string]*schedulernodeinfo.NodeInfo }