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
// 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,
}

View File

@@ -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))
}

View File

@@ -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)
}

View File

@@ -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))
}
}

View File

@@ -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.

View File

@@ -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
}