Assume full cgroup hierarchy only on gce and gke for e2e tests

Other cluster provider than gce or gke might have different cgroup layouts.
From outside we cannot know how these look like (especially in conformance test
which do not know the cluster provider at all).

Hence, this PR defaults to only the "/" cgroup to collect stats for. In the case
of gce or gke the full container list is tested.

Fixes https://github.com/mesosphere/kubernetes-mesos/issues/436
This commit is contained in:
Dr. Stefan Schimanski 2015-09-23 15:25:52 +02:00
parent f9f91fd99d
commit 643a7f193a
2 changed files with 19 additions and 10 deletions

View File

@ -103,7 +103,7 @@ var _ = Describe("kubelet", func() {
for _, node := range nodes.Items {
nodeNames.Insert(node.Name)
}
resourceMonitor = newResourceMonitor(framework.Client, targetContainers, containerStatsPollingInterval)
resourceMonitor = newResourceMonitor(framework.Client, targetContainers(), containerStatsPollingInterval)
resourceMonitor.Start()
})

View File

@ -178,12 +178,20 @@ const (
)
// A list of containers for which we want to collect resource usage.
var targetContainers = []string{
"/",
"/docker-daemon",
"/kubelet",
"/kube-proxy",
"/system",
func targetContainers() []string {
if providerIs("gce", "gke") {
return []string{
"/",
"/docker-daemon",
"/kubelet",
"/kube-proxy",
"/system",
}
} else {
return []string{
"/",
}
}
}
type containerResourceUsage struct {
@ -229,8 +237,9 @@ func getOneTimeResourceUsageOnNode(c *client.Client, nodeName string, cpuInterva
return nil, err
}
// Process container infos that are relevant to us.
usageMap := make(map[string]*containerResourceUsage, len(targetContainers))
for _, name := range targetContainers {
containers := targetContainers()
usageMap := make(map[string]*containerResourceUsage, len(containers))
for _, name := range containers {
info, ok := containerInfos[name]
if !ok {
return nil, fmt.Errorf("missing info for container %q on node %q", name, nodeName)
@ -491,7 +500,7 @@ func (r *resourceMonitor) LogCPUSummary() {
buf := &bytes.Buffer{}
w := tabwriter.NewWriter(buf, 1, 0, 1, ' ', 0)
fmt.Fprintf(w, "%s\n", strings.Join(header, "\t"))
for _, containerName := range targetContainers {
for _, containerName := range targetContainers() {
data := collector.GetBasicCPUStats(containerName)
var s []string
s = append(s, fmt.Sprintf("%q", containerName))