migrated comparer.go, dumper.go, node_tree.go to structured logging

This commit is contained in:
Shivanshu Raj Shrivastava 2021-10-28 15:15:43 +05:30
parent 927914dec7
commit 1a079d7b86
No known key found for this signature in database
GPG Key ID: F4EDF2ED69728499
3 changed files with 9 additions and 9 deletions

View File

@ -39,8 +39,8 @@ type CacheComparer struct {
// Compare compares the nodes and pods of NodeLister with Cache.Snapshot.
func (c *CacheComparer) Compare() error {
klog.V(3).Info("cache comparer started")
defer klog.V(3).Info("cache comparer finished")
klog.V(3).InfoS("Cache comparer started")
defer klog.V(3).InfoS("Cache comparer finished")
nodes, err := c.NodeLister.List(labels.Everything())
if err != nil {
@ -57,11 +57,11 @@ func (c *CacheComparer) Compare() error {
pendingPods := c.PodQueue.PendingPods()
if missed, redundant := c.CompareNodes(nodes, dump.Nodes); len(missed)+len(redundant) != 0 {
klog.InfoS("cache mismatch", "missed nodes", missed, "redundant nodes", redundant)
klog.InfoS("Cache mismatch", "missedNodes", missed, "redundantNodes", redundant)
}
if missed, redundant := c.ComparePods(pods, pendingPods, dump.Nodes); len(missed)+len(redundant) != 0 {
klog.InfoS("cache mismatch", "missed pods", missed, "redundant pods", redundant)
klog.InfoS("Cache mismatch", "missedPods", missed, "redundantPods", redundant)
}
return nil

View File

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

View File

@ -53,7 +53,7 @@ func (nt *nodeTree) addNode(n *v1.Node) {
if na, ok := nt.tree[zone]; ok {
for _, nodeName := range na {
if nodeName == n.Name {
klog.Warningf("node %q already exist in the NodeTree", n.Name)
klog.InfoS("Node already exists in the NodeTree", "node", klog.KObj(n))
return
}
}
@ -62,7 +62,7 @@ func (nt *nodeTree) addNode(n *v1.Node) {
nt.zones = append(nt.zones, zone)
nt.tree[zone] = []string{n.Name}
}
klog.V(2).Infof("Added node %q in group %q to NodeTree", n.Name, zone)
klog.V(2).InfoS("Added node in listed group to NodeTree", "node", klog.KObj(n), "zone", zone)
nt.numNodes++
}
@ -76,13 +76,13 @@ func (nt *nodeTree) removeNode(n *v1.Node) error {
if len(nt.tree[zone]) == 0 {
nt.removeZone(zone)
}
klog.V(2).Infof("Removed node %q in group %q from NodeTree", n.Name, zone)
klog.V(2).InfoS("Removed node in listed group from NodeTree", "node", klog.KObj(n), "zone", zone)
nt.numNodes--
return nil
}
}
}
klog.Errorf("Node %q in group %q was not found", n.Name, zone)
klog.ErrorS(nil, "Node in listed group was not found", "node", klog.KObj(n), "zone", zone)
return fmt.Errorf("node %q in group %q was not found", n.Name, zone)
}