Rename cache's Snapshot to Dump

Signed-off-by: Aldo Culquicondor <acondor@google.com>
This commit is contained in:
Aldo Culquicondor
2020-01-13 14:38:25 -05:00
parent 50f9ea7999
commit 6a14203658
6 changed files with 14 additions and 14 deletions

View File

@@ -177,7 +177,7 @@ func (cache *schedulerCache) removeNodeInfoFromList(name string) {
// debugging purposes only and shouldn't be confused with UpdateNodeInfoSnapshot // debugging purposes only and shouldn't be confused with UpdateNodeInfoSnapshot
// function. // function.
// This method is expensive, and should be only used in non-critical path. // 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() cache.mu.RLock()
defer cache.mu.RUnlock() defer cache.mu.RUnlock()
@@ -191,7 +191,7 @@ func (cache *schedulerCache) Snapshot() *Snapshot {
assumedPods[k] = v assumedPods[k] = v
} }
return &Snapshot{ return &Dump{
Nodes: nodes, Nodes: nodes,
AssumedPods: assumedPods, AssumedPods: assumedPods,
} }

View File

@@ -398,7 +398,7 @@ func TestSnapshot(t *testing.T) {
} }
} }
snapshot := cache.Snapshot() snapshot := cache.Dump()
if len(snapshot.Nodes) != len(cache.nodes) { 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)) t.Errorf("Unequal number of nodes in the cache and its snapshot. expected: %v, got: %v", len(cache.nodes), len(snapshot.Nodes))
} }

View File

@@ -52,15 +52,15 @@ func (c *CacheComparer) Compare() error {
return err return err
} }
snapshot := c.Cache.Snapshot() dump := c.Cache.Dump()
pendingPods := c.PodQueue.PendingPods() 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) 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) klog.Warningf("cache mismatch: missed pods: %s; redundant pods: %s", missed, redundant)
} }

View File

@@ -43,9 +43,9 @@ func (d *CacheDumper) DumpAll() {
// dumpNodes writes NodeInfo to the scheduler logs. // dumpNodes writes NodeInfo to the scheduler logs.
func (d *CacheDumper) dumpNodes() { func (d *CacheDumper) dumpNodes() {
snapshot := d.cache.Snapshot() dump := d.cache.Dump()
klog.Info("Dump of cached NodeInfo") klog.Info("Dump of cached NodeInfo")
for _, nodeInfo := range snapshot.Nodes { for _, nodeInfo := range dump.Nodes {
klog.Info(d.printNodeInfo(nodeInfo)) klog.Info(d.printNodeInfo(nodeInfo))
} }
} }

View File

@@ -89,8 +89,8 @@ func (c *Cache) FilteredList(filter schedulerlisters.PodFilter, selector labels.
} }
// Snapshot is a fake method for testing // Snapshot is a fake method for testing
func (c *Cache) Snapshot() *internalcache.Snapshot { func (c *Cache) Dump() *internalcache.Dump {
return &internalcache.Snapshot{} return &internalcache.Dump{}
} }
// GetNodeInfo is a fake method for testing. // GetNodeInfo is a fake method for testing.

View File

@@ -102,12 +102,12 @@ type Cache interface {
// on this node. // on this node.
UpdateNodeInfoSnapshot(nodeSnapshot *nodeinfosnapshot.Snapshot) error UpdateNodeInfoSnapshot(nodeSnapshot *nodeinfosnapshot.Snapshot) error
// Snapshot takes a snapshot on current cache // Dump produces a dump of the current cache.
Snapshot() *Snapshot Dump() *Dump
} }
// Snapshot is a snapshot of cache state // Dump is a dump of the cache state.
type Snapshot struct { type Dump struct {
AssumedPods map[string]bool AssumedPods map[string]bool
Nodes map[string]*schedulernodeinfo.NodeInfo Nodes map[string]*schedulernodeinfo.NodeInfo
} }