Merge pull request #38462 from gmarek/print

Automatic merge from submit-queue

Make resource gatherer print the data about resource usage in case of…
pull/6/head
Kubernetes Submit Queue 2016-12-09 06:07:57 -08:00 committed by GitHub
commit 52e1b36961
2 changed files with 9 additions and 6 deletions

View File

@ -388,7 +388,9 @@ func (f *Framework) AfterEach() {
summaries := make([]TestDataSummary, 0)
if TestContext.GatherKubeSystemResourceUsageData != "false" && TestContext.GatherKubeSystemResourceUsageData != "none" && f.gatherer != nil {
By("Collecting resource usage data")
summaries = append(summaries, f.gatherer.stopAndSummarize([]int{90, 99, 100}, f.AddonResourceConstraints))
summary, resourceViolationError := f.gatherer.stopAndSummarize([]int{90, 99, 100}, f.AddonResourceConstraints)
defer ExpectNoError(resourceViolationError)
summaries = append(summaries, summary)
}
if TestContext.GatherLogsSizes {

View File

@ -28,7 +28,6 @@ import (
"text/tabwriter"
"time"
. "github.com/onsi/gomega"
"k8s.io/kubernetes/pkg/api/v1"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
utilruntime "k8s.io/kubernetes/pkg/util/runtime"
@ -295,7 +294,7 @@ func (g *containerResourceGatherer) startGatheringData() {
g.getKubeSystemContainersResourceUsage(g.client)
}
func (g *containerResourceGatherer) stopAndSummarize(percentiles []int, constraints map[string]ResourceConstraint) *ResourceUsageSummary {
func (g *containerResourceGatherer) stopAndSummarize(percentiles []int, constraints map[string]ResourceConstraint) (*ResourceUsageSummary, error) {
close(g.stopCh)
Logf("Closed stop channel. Waiting for %v workers", len(g.workers))
finished := make(chan struct{})
@ -318,7 +317,7 @@ func (g *containerResourceGatherer) stopAndSummarize(percentiles []int, constrai
if len(percentiles) == 0 {
Logf("Warning! Empty percentile list for stopAndPrintData.")
return &ResourceUsageSummary{}
return &ResourceUsageSummary{}, nil
}
data := make(map[int]ResourceUsagePerContainer)
for i := range g.workers {
@ -373,6 +372,8 @@ func (g *containerResourceGatherer) stopAndSummarize(percentiles []int, constrai
}
}
}
Expect(violatedConstraints).To(BeEmpty())
return &summary
if len(violatedConstraints) > 0 {
return &summary, fmt.Errorf(strings.Join(violatedConstraints, "\n"))
}
return &summary, nil
}