mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Add process debug information to summary test
This commit is contained in:
parent
f53ba5581b
commit
9a1236ae20
@ -18,6 +18,8 @@ package e2e_node
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
@ -37,9 +39,14 @@ var _ = framework.KubeDescribe("Summary API", func() {
|
|||||||
f := framework.NewDefaultFramework("summary-test")
|
f := framework.NewDefaultFramework("summary-test")
|
||||||
Context("when querying /stats/summary", func() {
|
Context("when querying /stats/summary", func() {
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
if CurrentGinkgoTestDescription().Failed && framework.TestContext.DumpLogsOnFailure {
|
if !CurrentGinkgoTestDescription().Failed {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if framework.TestContext.DumpLogsOnFailure {
|
||||||
framework.LogFailedContainers(f.ClientSet, f.Namespace.Name, framework.Logf)
|
framework.LogFailedContainers(f.ClientSet, f.Namespace.Name, framework.Logf)
|
||||||
}
|
}
|
||||||
|
By("Recording processes in system cgroups")
|
||||||
|
recordSystemCgroupProcesses()
|
||||||
})
|
})
|
||||||
It("should report resource usage through the stats api", func() {
|
It("should report resource usage through the stats api", func() {
|
||||||
const pod0 = "stats-busybox-0"
|
const pod0 = "stats-busybox-0"
|
||||||
@ -299,3 +306,39 @@ func recent(d time.Duration) types.GomegaMatcher {
|
|||||||
// Now() is the test start time, not the match time, so permit a few extra minutes.
|
// Now() is the test start time, not the match time, so permit a few extra minutes.
|
||||||
BeTemporally("<", time.Now().Add(2*time.Minute))))
|
BeTemporally("<", time.Now().Add(2*time.Minute))))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func recordSystemCgroupProcesses() {
|
||||||
|
cfg, err := getCurrentKubeletConfig()
|
||||||
|
if err != nil {
|
||||||
|
framework.Logf("Failed to read kubelet config: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cgroups := map[string]string{
|
||||||
|
"kubelet": cfg.KubeletCgroups,
|
||||||
|
"runtime": cfg.RuntimeCgroups,
|
||||||
|
"misc": cfg.SystemCgroups,
|
||||||
|
}
|
||||||
|
for name, cgroup := range cgroups {
|
||||||
|
if cgroup == "" {
|
||||||
|
framework.Logf("Skipping unconfigured cgroup %s", name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
pids, err := ioutil.ReadFile(fmt.Sprintf("/sys/fs/cgroup/cpu/%s/cgroup.procs", cgroup))
|
||||||
|
if err != nil {
|
||||||
|
framework.Logf("Failed to read processes in cgroup %s: %v", name, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
framework.Logf("Processes in %s cgroup (%s):", name, cgroup)
|
||||||
|
for _, pid := range strings.Fields(string(pids)) {
|
||||||
|
path := fmt.Sprintf("/proc/%s/cmdline", pid)
|
||||||
|
cmd, err := ioutil.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
framework.Logf(" Failed to read %s: %v", path, err)
|
||||||
|
} else {
|
||||||
|
framework.Logf(" %s", cmd)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user