mirror of https://github.com/k3s-io/k3s
Benchmark non docker specific
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>pull/6/head
parent
bc361fae40
commit
3660563e22
|
@ -85,16 +85,16 @@ func NewResourceCollector(interval time.Duration) *ResourceCollector {
|
||||||
// Start starts resource collector and connects to the standalone Cadvisor pod
|
// Start starts resource collector and connects to the standalone Cadvisor pod
|
||||||
// then repeatedly runs collectStats.
|
// then repeatedly runs collectStats.
|
||||||
func (r *ResourceCollector) Start() {
|
func (r *ResourceCollector) Start() {
|
||||||
// Get the cgroup container names for kubelet and docker
|
// Get the cgroup container names for kubelet and runtime
|
||||||
kubeletContainer, err := getContainerNameForProcess(kubeletProcessName, "")
|
kubeletContainer, err := getContainerNameForProcess(kubeletProcessName, "")
|
||||||
dockerContainer, err := getContainerNameForProcess(dockerProcessName, dockerPidFile)
|
runtimeContainer, err := getContainerNameForProcess(framework.TestContext.ContainerRuntimeProcessName, framework.TestContext.ContainerRuntimePidFile)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
systemContainers = map[string]string{
|
systemContainers = map[string]string{
|
||||||
stats.SystemContainerKubelet: kubeletContainer,
|
stats.SystemContainerKubelet: kubeletContainer,
|
||||||
stats.SystemContainerRuntime: dockerContainer,
|
stats.SystemContainerRuntime: runtimeContainer,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
framework.Failf("Failed to get docker container name in test-e2e-node resource collector.")
|
framework.Failf("Failed to get runtime container name in test-e2e-node resource collector.")
|
||||||
}
|
}
|
||||||
|
|
||||||
wait.Poll(1*time.Second, 1*time.Minute, func() (bool, error) {
|
wait.Poll(1*time.Second, 1*time.Minute, func() (bool, error) {
|
||||||
|
@ -240,12 +240,11 @@ func (r *ResourceCollector) GetBasicCPUStats(containerName string) map[float64]f
|
||||||
func formatResourceUsageStats(containerStats framework.ResourceUsagePerContainer) string {
|
func formatResourceUsageStats(containerStats framework.ResourceUsagePerContainer) string {
|
||||||
// Example output:
|
// Example output:
|
||||||
//
|
//
|
||||||
// Resource usage for node "e2e-test-foo-node-abcde":
|
// Resource usage:
|
||||||
// container cpu(cores) memory(MB)
|
//container cpu(cores) memory_working_set(MB) memory_rss(MB)
|
||||||
// "/" 0.363 2942.09
|
//"kubelet" 0.068 27.92 15.43
|
||||||
// "/docker-daemon" 0.088 521.80
|
//"runtime" 0.664 89.88 68.13
|
||||||
// "/kubelet" 0.086 424.37
|
|
||||||
// "/system" 0.007 119.88
|
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
w := tabwriter.NewWriter(buf, 1, 0, 1, ' ', 0)
|
w := tabwriter.NewWriter(buf, 1, 0, 1, ' ', 0)
|
||||||
fmt.Fprintf(w, "container\tcpu(cores)\tmemory_working_set(MB)\tmemory_rss(MB)\n")
|
fmt.Fprintf(w, "container\tcpu(cores)\tmemory_working_set(MB)\tmemory_rss(MB)\n")
|
||||||
|
@ -258,7 +257,7 @@ func formatResourceUsageStats(containerStats framework.ResourceUsagePerContainer
|
||||||
|
|
||||||
func formatCPUSummary(summary framework.ContainersCPUSummary) string {
|
func formatCPUSummary(summary framework.ContainersCPUSummary) string {
|
||||||
// Example output for a node (the percentiles may differ):
|
// Example output for a node (the percentiles may differ):
|
||||||
// CPU usage of containers on node "e2e-test-foo-node-0vj7":
|
// CPU usage of containers:
|
||||||
// container 5th% 50th% 90th% 95th%
|
// container 5th% 50th% 90th% 95th%
|
||||||
// "/" 0.051 0.159 0.387 0.455
|
// "/" 0.051 0.159 0.387 0.455
|
||||||
// "/runtime 0.000 0.000 0.146 0.166
|
// "/runtime 0.000 0.000 0.146 0.166
|
||||||
|
@ -461,15 +460,7 @@ func (r *ResourceCollector) GetResourceTimeSeries() map[string]*perftype.Resourc
|
||||||
return resourceSeries
|
return resourceSeries
|
||||||
}
|
}
|
||||||
|
|
||||||
// Code for getting container name of docker, copied from pkg/kubelet/cm/container_manager_linux.go
|
const kubeletProcessName = "kubelet"
|
||||||
// since they are not exposed
|
|
||||||
const (
|
|
||||||
kubeletProcessName = "kubelet"
|
|
||||||
dockerProcessName = "docker"
|
|
||||||
dockerPidFile = "/var/run/docker.pid"
|
|
||||||
containerdProcessName = "docker-containerd"
|
|
||||||
containerdPidFile = "/run/docker/libcontainerd/docker-containerd.pid"
|
|
||||||
)
|
|
||||||
|
|
||||||
func getPidsForProcess(name, pidFile string) ([]int, error) {
|
func getPidsForProcess(name, pidFile string) ([]int, error) {
|
||||||
if len(pidFile) > 0 {
|
if len(pidFile) > 0 {
|
||||||
|
|
Loading…
Reference in New Issue