mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Reduce redundant Nodes().List() call
dumpAllNodeInfo() called Nodes().List() internally, but the function is called from DumpAllNamespaceInfo() only and DumpAllNamespaceInfo() calls Nodes().List() before calling dumpAllNodeInfo(). So this makes the result of Nodes().List() being passed to dumpAllNodeInfo() then reduce a call of Nodes().List().
This commit is contained in:
parent
02a2d79bde
commit
da85510bd3
@ -1775,7 +1775,7 @@ func DumpAllNamespaceInfo(c clientset.Interface, namespace string) {
|
||||
return
|
||||
}
|
||||
if len(nodes.Items) <= maxNodesForDump {
|
||||
dumpAllNodeInfo(c)
|
||||
dumpAllNodeInfo(c, nodes)
|
||||
} else {
|
||||
e2elog.Logf("skipping dumping cluster info - cluster too large")
|
||||
}
|
||||
@ -1794,13 +1794,7 @@ func (o byFirstTimestamp) Less(i, j int) bool {
|
||||
return o[i].FirstTimestamp.Before(&o[j].FirstTimestamp)
|
||||
}
|
||||
|
||||
func dumpAllNodeInfo(c clientset.Interface) {
|
||||
// It should be OK to list unschedulable Nodes here.
|
||||
nodes, err := c.CoreV1().Nodes().List(metav1.ListOptions{})
|
||||
if err != nil {
|
||||
e2elog.Logf("unable to fetch node list: %v", err)
|
||||
return
|
||||
}
|
||||
func dumpAllNodeInfo(c clientset.Interface, nodes *v1.NodeList) {
|
||||
names := make([]string, len(nodes.Items))
|
||||
for ix := range nodes.Items {
|
||||
names[ix] = nodes.Items[ix].Name
|
||||
|
Loading…
Reference in New Issue
Block a user