Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: print runtime MemStats when memory usage exceeds expectation #22404

Merged
merged 1 commit into from
Mar 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions test/e2e/kubelet_perf.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func runResourceTrackingTest(framework *Framework, podsPerNode int, nodeNames se
usageSummary, err := rm.GetLatest()
Expect(err).NotTo(HaveOccurred())
Logf("%s", rm.FormatResourceUsage(usageSummary))
verifyMemoryLimits(expectedMemory, usageSummary)
verifyMemoryLimits(framework.Client, expectedMemory, usageSummary)

cpuSummary := rm.GetCPUSummary()
Logf("%s", rm.FormatCPUSummary(cpuSummary))
Expand All @@ -109,7 +109,7 @@ func runResourceTrackingTest(framework *Framework, podsPerNode int, nodeNames se
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 {
return
}
Expand All @@ -132,10 +132,16 @@ func verifyMemoryLimits(expected resourceUsagePerContainer, actual resourceUsage
}
if len(nodeErrs) > 0 {
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 {
Failf("CPU usage exceeding limits:\n %s", strings.Join(errList, "\n"))
Failf("Memory usage exceeding limits:\n %s", strings.Join(errList, "\n"))
}
}

Expand Down
16 changes: 16 additions & 0 deletions test/e2e/kubelet_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,22 @@ func getKubeletMetricsThroughNode(nodeName string) (string, error) {
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
// includes necessary information (e.g., UID, name, namespace for
// pods/containers), but do not contain the full spec.
Expand Down