mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 15:58:37 +00:00
Merge pull request #22404 from yujuhong/dump_mem
Auto commit by PR queue bot
This commit is contained in:
commit
5efa8aa7d1
@ -99,7 +99,7 @@ func runResourceTrackingTest(framework *Framework, podsPerNode int, nodeNames se
|
|||||||
usageSummary, err := rm.GetLatest()
|
usageSummary, err := rm.GetLatest()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Logf("%s", rm.FormatResourceUsage(usageSummary))
|
Logf("%s", rm.FormatResourceUsage(usageSummary))
|
||||||
verifyMemoryLimits(expectedMemory, usageSummary)
|
verifyMemoryLimits(framework.Client, expectedMemory, usageSummary)
|
||||||
|
|
||||||
cpuSummary := rm.GetCPUSummary()
|
cpuSummary := rm.GetCPUSummary()
|
||||||
Logf("%s", rm.FormatCPUSummary(cpuSummary))
|
Logf("%s", rm.FormatCPUSummary(cpuSummary))
|
||||||
@ -109,7 +109,7 @@ func runResourceTrackingTest(framework *Framework, podsPerNode int, nodeNames se
|
|||||||
DeleteRC(framework.Client, framework.Namespace.Name, rcName)
|
DeleteRC(framework.Client, framework.Namespace.Name, rcName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyMemoryLimits(expected resourceUsagePerContainer, actual resourceUsagePerNode) {
|
func verifyMemoryLimits(c *client.Client, expected resourceUsagePerContainer, actual resourceUsagePerNode) {
|
||||||
if expected == nil {
|
if expected == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -132,6 +132,12 @@ func verifyMemoryLimits(expected resourceUsagePerContainer, actual resourceUsage
|
|||||||
}
|
}
|
||||||
if len(nodeErrs) > 0 {
|
if len(nodeErrs) > 0 {
|
||||||
errList = append(errList, fmt.Sprintf("node %v:\n %s", nodeName, strings.Join(nodeErrs, ", ")))
|
errList = append(errList, fmt.Sprintf("node %v:\n %s", nodeName, strings.Join(nodeErrs, ", ")))
|
||||||
|
heapStats, err := getKubeletHeapStats(c, nodeName)
|
||||||
|
if err != nil {
|
||||||
|
Logf("Unable to get heap stats from %q", nodeName)
|
||||||
|
} else {
|
||||||
|
Logf("Heap stats on %q\n:%v", nodeName, heapStats)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(errList) > 0 {
|
if len(errList) > 0 {
|
||||||
|
@ -407,6 +407,22 @@ func getKubeletMetricsThroughNode(nodeName string) (string, error) {
|
|||||||
return string(body), nil
|
return string(body), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getKubeletHeapStats(c *client.Client, nodeName string) (string, error) {
|
||||||
|
client, err := nodeProxyRequest(c, nodeName, "debug/pprof/heap")
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
raw, errRaw := client.Raw()
|
||||||
|
if errRaw != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
stats := string(raw)
|
||||||
|
// Only dumping the runtime.MemStats numbers to avoid polluting the log.
|
||||||
|
numLines := 23
|
||||||
|
lines := strings.Split(stats, "\n")
|
||||||
|
return strings.Join(lines[len(lines)-numLines:], "\n"), nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetKubeletPods retrieves the list of running pods on the kubelet. The pods
|
// GetKubeletPods retrieves the list of running pods on the kubelet. The pods
|
||||||
// includes necessary information (e.g., UID, name, namespace for
|
// includes necessary information (e.g., UID, name, namespace for
|
||||||
// pods/containers), but do not contain the full spec.
|
// pods/containers), but do not contain the full spec.
|
||||||
|
Loading…
Reference in New Issue
Block a user